0
我在尋找練習和遊戲表中不存在的條目,但是我無法在語句中使用第二個條目。有沒有其他方法可以做到這一點?無法在語句中使用多個
select VenueID from Venue
where VenueID not in (select VenueID from Practice)
and not in (select VenueId from Game)
我在尋找練習和遊戲表中不存在的條目,但是我無法在語句中使用第二個條目。有沒有其他方法可以做到這一點?無法在語句中使用多個
select VenueID from Venue
where VenueID not in (select VenueID from Practice)
and not in (select VenueId from Game)
您需要重複NOT IN
聲明,包括列名稱:
SELECT VenueID
FROM Venue
WHERE VenueID NOT IN (SELECT VenueID FROM Practice) AND
VenueID NOT IN (SELECT VenueId FROM Game)
^^^ you omitted the second column name
One alterna傾向於使用NOT IN
將做兩個左連接:
SELECT VenueID
FROM Venue t1
LEFT JOIN Practice t2
ON t1.VenueID = t2.VenueID
LEFT JOIN Game t3
ON t1.VenueID = t3.VenueID
WHERE t2.VenueID IS NULL AND
t3.VenueID IS NULL
你在第二not in
缺少列名(每個標準是不同的,其語法是<列> NOT IN> <值設置):
select VenueID from Venue
where VenueID not in (select VenueID from Practice)
and VenueID not in (select VenueId from Game)
-- ^^^^^^^