(If you're not using a programming language, you'll be limited to just the third and fourth issues.) To debug such situations, you need to identify the actual cause of the problem.
If using a programming language to create an SQL query, print out the query so that you know exactly what is trying to be executed. Frequently, the program is not assembling a query as you would expect.
Run the query on the database via another method, such as using the mysql client. Doing so will validate both the SQL and the results.
In a programming language, use the methods available for reporting any MySQL errors.
If the query results are bad, rewrite the query in its most basic form. Then keep adding dimensions back in until you discover which clause is causing the problem.
Pay attention to what versions you are using (of MySQL and the languages) and reread any applicable manual pages to see if this is a version-specific issue.