使用 mysql 数据库我试图根据他们的电子邮件地址获取 100 人的用户 ID。我有所有用户的电子邮件地址,但是当我对多条记录运行查询时,它不起作用。对于单个记录其工作。我在下面试过。
Select ID
from users
where email_address IN ("[email protected], [email protected], [email protected]")
也试过这个
Select ID
from users
where email_address = ("[email protected], [email protected], [email protected]")
但他们没有工作。
对于单条记录,它可以工作,但我需要多条记录。你能帮我找出我错在哪里吗?
This is for single one
select ID from users where email_address = "[email protected]".
您将单个字符串传递给IN
. 反而:
where email_address IN ('[email protected]', '[email protected]', . . . )
这是一个字符串列表。
如果您将列表作为参数传入,您可能打算find_in_set()
:
where find_in_set(email_address, '[email protected],[email protected],...')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句