开发者

MySql skips first record found

开发者 https://www.devze.com 2022-12-08 23:17 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号