By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,543 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

How to diagnose a query problem

Claus Mygind
100+
P: 571
I am have a problem with a query that does not return a rowset.

Expand|Select|Wrap|Line Numbers
  1. select t1.*, t2.name, t2.addr1, t2.addr2, t2.city, t2.st, t2.zip, t2.phone, t2.fax from contact t1 left join master t2 on t1.id=t2.id where t1.addDate between "2012-01-28" and "2012-02-27" order by t1.last, t1.first
What is unusual about the problem is, I can either delete one of the columns in the select OR add an additional column and the query will execute perfectly fine.

I have tried the following to solve the problem and still cannot figure out what is wrong.

1) encapsulated the column names like this
Expand|Select|Wrap|Line Numbers
  1. select t1.*, t2.`name`, t2.`addr1`,... from `contact` t1 left join `master` t2 on t1.`id`=t2.`id` where t1.`addDate` between "2012-01-28" and "2012-02-27" order by t1.`last`, t1.`first`
2) viewing the query in a hex editor (I generate the query in an app on the fly) in my app.

I just find it odd, since I can either add or delete a column and the query will return a row set.

I recognize I have some badly named columns name, first, last. But the encapsulation should take care of that. Plus I use these column names in other queries with no problem.

Question? What other measures can I take to diagnose the problem?
Feb 27 '12 #1

✓ answered by Claus Mygind

Still not sure why it does not work on the MySQL Query Browser. But the answer in the php app came down to a simple comparison operator

if (rowset == 0 ) vs. if (rowset > 0)

Not working in the query browser is what threw me off the scent.

Share this Question
Share on Google+
2 Replies


Claus Mygind
100+
P: 571
And to make my problem even more odd. I can execute the same query from dBase app and it works fine (returns 156 rows) but when executed from either my php app or from the MySQL Query Browser it fails and returns 0 rows.

I have now run a maintenance check on the tables and they are ok.
Feb 27 '12 #2

Claus Mygind
100+
P: 571
Still not sure why it does not work on the MySQL Query Browser. But the answer in the php app came down to a simple comparison operator

if (rowset == 0 ) vs. if (rowset > 0)

Not working in the query browser is what threw me off the scent.
Feb 27 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.