我在下面有一个查询,想知道是否可以获得超过 1 个结果。我想获取 4 个最新的条目。
谢谢!
select c.email,c.text,m.alertDataID
from client_users as c, monitor_alerts as a, monitor_alerts_data as m
where c.id=a.userID and a.alertID=m.alertID and
m.alertDataID = (SELECT alertDataID FROM monitor_alerts_data ORDER BY alertDataID DESC LIMIT 1)
LIMIT 4
最佳答案
使用IN
代替=
:
... and m.alertDataID IN (SELECT alertDataID FROM ...)
也不要将您的子查询限制为 LIMIT 1
。您需要在子查询中使用 LIMIT 4
。
关于mysql - 如何在 SQL 子查询中返回多个结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3844049/