MySql skips first record found
in my database i have 10 records with almost exact same data , they differ only by one field ( the field is n开发者_如何学Goot in the query) and when i run the following query
SELECT * FROM friends WHERE user_id= 'MyUserName' AND follow_back = 0 AND until_date= '2009-10-13' LIMIT 12
it shows only 9 records , any one stumbled upon similar problem ? Thanks & waiting for your answers !
The short answer is there's nothing wrong with your query, so
user_id!='MyUserName'
or
follow_back != 0
or
until_date != '2009-10-13'
Try just querying on one criterion at a time and see if you can norrow it down. Perhaps follow_back
is NULL?
When trying to debug problems like these, what I would usually do is to try solving it using a divide and conquer approach.
So try and remove one where condition at a time, then execute the query. That way you will be able to isolate the offending condition.
Good luck
Are you sure, that all values in column user_id are the same? Maybe that one missing record has user_id = 'MyUserName ' (note the space).
I had the same problem a minute ago. It turned out it wasn't the query that was the problem, but the IF where I check if anything's returned. Might want to check that.
精彩评论