MySQL 'WHERE AND' 问题 [英] MySQL 'WHERE AND' issue

查看:51
本文介绍了MySQL 'WHERE AND' 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我正在尝试从数据库中收集一些已定义的电子邮件,我通过每个客户的 ID 收集它们.

I've got an issue, I am trying to collect a number of defined emails from a database, I collect them via the ID of each client.

因此,我目前在数据库中有 1000 个用户,我只想要来自 ID 10、11、23、34、56、33、340、433、434 等的电子邮件...

Therefore, I currently have 1000 users in the database and I only want the emails from IDs 10, 11, 23, 34, 56, 33, 340, 433, 434, etc...

除了

SELECT email FROM users WHERE id=10 OR id=11 OR id=23 OR id=34... 

etc" 有没有其他方法可以同时包含所有 ID,而不必每次都编写 OR 条件并添加 ID?

etc" is there any other method that I could includes all the IDs simultaneously without having to write an OR condition each time and ID is added?

谢谢.

推荐答案

使用 IN

SELECT email 
FROM users 
WHERE ID IN (34, 56, 33, 340, 433, 434)

这篇关于MySQL 'WHERE AND' 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆