gpt4 book ai didi

mysql - 如何在 SQL 子查询中返回多个结果?

转载 作者:搜寻专家 更新时间:2023-10-30 20:06:34 27 4
gpt4 key购买 nike

我在下面有一个查询,想知道是否可以获得超过 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com