MYSQL 不等于“IN”询问

发布于 2024-12-21 17:30:37 字数 188 浏览 2 评论 0 原文

我有一个包含大量 id 的表,但我不想选择大约 10 个 id

首先我尝试了多个 OR 但不起作用,然后找到了 IN

SELECT * FROM table WHERE id IN (10, 88, 99)

但这选择了那些我想要所有其他数字的数字,因此 a 不等于需要去某个地方

I have a table with loads of id's but I don't want to select around 10 id's

First I tried multiple OR but that didn't work then found the IN

SELECT * FROM table WHERE id IN (10, 88, 99)

But this selects those numbers I want all the other numbers so a not equal to needs to go in somewhere

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

触ぅ动初心 2024-12-28 17:30:37

试试这个:

 SELECT * FROM table WHERE id NOT IN (10, 88, 99)

希望这有帮助

Try this:

 SELECT * FROM table WHERE id NOT IN (10, 88, 99)

Hope this helps

喜爱皱眉﹌ 2024-12-28 17:30:37
Select * from table where Id NOT IN (10,88,99)
Select * from table where Id NOT IN (10,88,99)
幸福丶如此 2024-12-28 17:30:37

正确的查询是:

SELECT * FROM `table` WHERE `id` NOT IN (10, 88, 99)

并且您对“多个 OR”的尝试失败了,可能是因为它应该涉及“多个 AND”和这样的否定:

SELECT * FROM `table` WHERE `id`!=10 AND `id`!=88 AND `id`!=99

Correct query is:

SELECT * FROM `table` WHERE `id` NOT IN (10, 88, 99)

And your attempt with "multiple ORs" failed probably because of it should involve "multiple ANDs" and negations like that:

SELECT * FROM `table` WHERE `id`!=10 AND `id`!=88 AND `id`!=99
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文