gpt4 book ai didi

mysql - 如何获取具有多个值的所有行

转载 作者:行者123 更新时间:2023-11-29 06:35:56 25 4
gpt4 key购买 nike

SELECT *
FROM Service
WHERE cusId='$cusId'
AND serviceType IN (1,2)
ORDER BY date DESC LIMIT 2

我想要 serviceType 为 1 和 2 的服务的最后记录,当我将此脚本与 IN 查询一起使用时,我得到 2 行 serviceType 为 1 的服务,但我想要有两条记录,它们具有1 和 2 作为服务类型,对不起我的英语

最佳答案

(select * from Service 
where cusId='$cusId'
and serviceType = 1
order by date desc limit 1)

UNION

(select * from Service
where cusId='$cusId'
and serviceType = 2
order by date desc limit 1)

关于mysql - 如何获取具有多个值的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24821470/

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