下表:
ReviewPicture(rid, pid)
ArticlePicture(aid, pid)
Picture(pid, filename)
我希望在不使用联接的情况下获取既未在ArticlePicture
也未在ReviewPicture
中使用的图片ID。
这就是我到目前为止所做的 - 不幸的是我在Picture
中得到了所有图片:
select distinct Picture.pid
FROM Picture, ReviewPicture, ArticlePicture
where Picture.pid <> ReviewPicture.pid
AND Picture.pid <> ArticlePicture.pid;
答案 0 :(得分:0)
您可以使用子查询
SELECT DISTINCT Picture.pid FROM Picture
WHERE PID NOT IN (SELECT PID FROM ReviewPicture) AND PID NOT IN (SELECT PID FROM ArticlePicture)