Why can't I find data when mysql uses notin?

Source: Internet
Author: User
Why can't I find data when mysql uses notin. Select & nbsp; id, cid, title, keywords, hits, addtime & nbsp; from & nbsp; 'articles' & nbsp; where & nbsp; id & nbsp; not & nbsp; in (4454,4453, 4452,4451 why does mysql use not in.
Select id, cid, title, keywords, hits, addtime from 'article' where id not in (4454,4453, 4452,4451, 4450,4449, 4448,4447) order by addtime desc, id desc LIMIT 0, 18


The preceding statement removes not in and has data. This is why. The database contains more than 4000 data records ranging from 1 to 4454. It cannot be found. And it was okay before, and I suddenly couldn't find it. Very strange. Share:
------ Solution --------------------
It seems that the not in mysql has a certain bug. I have also encountered that the result of direct not in (values) query is 0.
You can try it like this:
Create a new table, such as ids, with only one id field. Insert 4454,4453, 4452,4451, 4450,4449, 4448,4447 into the table, and then query it like this:
Select id, cid, title, keywords, hits, addtime from 'article' where id not in (select id from ids) order by addtime desc, id desc LIMIT 0, 18;
I did this before, hoping to help you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.