以下查询返回我要查找的内容。
SELECT * from meetings where meetings.date = '2018-03-12';
但是,下面给出的是
未知专栏''2018'在' where子句'
SELECT roomNumber
FROM rooms
WHERE NOT EXISTS
( SELECT *
FROM meetings
WHERE rooms.roomNumber = meetings.room
AND meetings.date = ‘2018-03-12’ );
我在没有单引号的情况下尝试了2018-03-12,并且它有效。但是,这不会返回正确的记录集。我正在寻找当天没有开会的可用房间。
答案 0 :(得分:1)
试试这个
SELECT roomNumber
FROM rooms
WHERE NOT EXISTS
( SELECT *
FROM meetings
WHERE rooms.roomNumber = meetings.room
AND meetings.date = '2018-03-12' );
这基本上是@BoarGules评论的修正,你使用的是智能引号:‘2018-03-12’
而不是单引号:'2018-03-12'
答案 1 :(得分:-1)
SELECT roomNumber
FROM rooms
WHERE NOT EXISTS IN
( SELECT rooms.roomNumber
FROM meetings
WHERE rooms.roomNumber = meetings.room
AND meetings.date = 2018-03-12 );
尝试使用此查询