MySQL与WHERE一起加入

时间:2010-02-18 14:00:43

标签: sql mysql tsql

我有2张桌子,想要查询与艺术家一起加入的所有专辑数据

artists: artist_id | name

albums: album_id | artist_id | songs

这只给了我第一行

SELECT * FROM albums JOIN artists ON artists.artist_id = albums.artist_id

我想指定一个专辑ID

SELECT * FROM albums 
   WHERE album_id = 101 
JOIN artists ON artists.artist_id = albums.artist_id

1 个答案:

答案 0 :(得分:5)

WHERE追踪JOIN

SELECT  *
FROM    albums
JOIN    artists
ON      artists.artist_id = albums.artist_id
WHERE   album_id = 101