如何从一张桌子中选择一个拍卖ID,在另一张桌子中,拍卖ID为null请问,我有没有办法尝试为null但不工作有人可以帮忙吗?希望能得到答案
SELECT Auction.AuctionID
FROM Item
INNER JOIN Auction ON Item.ItemID = Auction.ItemID
INNER JOIN BID ON Auction.AuctionID = BID.AuctionID
WHERE (Auction.Status = 'Valid') AND (BID.AuctionID IS NULL)
答案 0 :(得分:2)
您在拍卖和出价表之间使用内部联接。请改用左连接。
答案 1 :(得分:0)
查找没有出价的拍卖
SELECT Auction.AuctionID -- other columns
FROM Item
INNER JOIN Auction ON Item.ItemID = Auction.ItemID
Left outer JOIN BID ON Auction.AuctionID = BID.AuctionID
WHERE (Auction.Status = 'Valid') and bid.auctionid is null
Group by auction.auctionid
Having count(bid.auctionid) = 0