how to debug a query that has valid syntax, executes, but returns no results?

Posted by Ty W on Stack Overflow See other posts from Stack Overflow or by Ty W
Published on 2010-05-20T20:19:16Z Indexed on 2010/05/20 20:20 UTC
Read the original article Hit count: 208

Filed under:
|
|
|

So I'm writing a fairly involved query with a half dozen joins, a dependent subquery for [greatest-n-per-group] purposes, grouping, etc. It is syntactically valid, but I've clearly made at least one mistake because it returns nothing.

In the past I've debugged valid queries that return nothing by removing joins, executing subqueries on their own, removing WHERE conditions, and removing grouping to see what I would get but so far this one has me stumped. Are there better tools or techniques to use for this sort of thing?

This particular query is for MySQL if it matters for any platform-specific tools.

© Stack Overflow or respective owner

Related posts about sql

Related posts about debugging