我有两个表 - 艺术家和专辑
artist - id, name, artist_genre
中的列
专辑中的列 - id、name、artist_name、album_genre、release_date
我想找到专辑表中不属于艺术家表中所列流派的所有艺术家(更具体地说 - 如果艺术家 X 注册了流派“流行”和“摇滚”但制作了流派为 Y 的专辑'经典',则应列出艺术家、专辑和流派。
最佳答案
select artist_name, name, album_genre
from album left join artist on artist.name = album.artist_name and album_genre = artist_genre
where artist.id is null
关于mysql - Sql - 比较两个表时数据引用不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20965726/