gpt4 book ai didi

MySQL-选择收集第二个选择结果的地方

转载 作者:可可西里 更新时间:2023-11-01 07:53:13 26 4
gpt4 key购买 nike

我有这个问题。第二部分是获取正确的值,但最终输出数据仍然包括列等于选择值的行。

SELECT * 
FROM roomfacilities
WHERE room <> '(SELECT room_assigned
FROM allocation
WHERE booking_id = 01010106)';

我试图让它工作,说 SELECT all from roomfacilities WHERE room 'does not equal' result from select.

感谢您的帮助。

最佳答案

使用 NOT IN 谓词:

SELECT *
FROM roomfacilities
WHERE room NOT IN(SELECT room_assigned
FROM allocation
WHERE booking_id = 01010106);

或者: LEFT JOIN:

SELECT f.*
FROM roomfacilities f
LEFT JOIN allocation a ON f.room = a.room_assigned
AND a.booking_id = 01010106
WHERE a.room_assigned IS NULL;

关于MySQL-选择收集第二个选择结果的地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14937872/

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