The Query of Despair

Oh man. I know I’ve encountered something like this before. So many developers have absolutely no experience writing decent SQL. Its getting even worse these days with the prevalence of ORMs in all the big frameworks. When they do have to actually write a query, they just throw syntax together until it works, even if it ends up looking like this and taking 18 hours to run:

The Query of Despair - The Daily WTF