sql - MySQL JOIN ON 与 WHERE

标签 sql mysql tsql

我有2张表,想查询所有加入艺术家的专辑数据

艺术家:artist_id |姓名

相册:album_id |艺术家编号 |歌曲

这只给我第一行

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

最佳答案

WHEREJOIN 之后:

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

关于sql - MySQL JOIN ON 与 WHERE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2289077/

相关文章:

用于查找订单最后一个事件状态的 SQL 查询

Python:pandas read_sql_query

php mysql 从表循环行更新数组

sql - SQL 子查询中的 where 子句无效

sql - 使用具有特定条件的 LAG 获取上一行值

mysql - 检查日期是否在日期范围内

Mysql查询关注者列表

mysql - Left Outer Join 没有给出任何结果

python - 在 Django 项目上运行syncdb 不起作用 : Can't create/write to file

sql-server - 检查表中是否存在可能不存在的记录