gpt4 book ai didi

MySQL 从具有不同状态的列返回结果

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

我想从order_details表中查找所有order_id和product_id,其中orders表中的status_order不包含“O”,“E”,“P”...

SELECT `order_id`, `product_id`
FROM `order_details`
WHERE `order_id`
NOT IN (SELECT `order_id` FROM `orders`
WHERE
`status`="O" OR
`status`="E" OR
`status`="P" OR
`status`="F" OR
`status`="I" OR
`status`="Y" OR
`status`="B" OR
`status`="J" OR
`status`="H" OR
`status`="G" OR
`status`="D")

最佳答案

select od.order_id ,od.product_id
from order_details od
inner join orders os
on od.order_id = os.order_id
where os.status_order not in ('o','e','p')

关于MySQL 从具有不同状态的列返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35600213/

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