Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 需要帮助发现小查询中的SQL语法错误吗_Mysql_Sql_Database_Syntax_Relational Database - Fatal编程技术网

Mysql 需要帮助发现小查询中的SQL语法错误吗

Mysql 需要帮助发现小查询中的SQL语法错误吗,mysql,sql,database,syntax,relational-database,Mysql,Sql,Database,Syntax,Relational Database,我在下面代码的“第5行”附近遇到一个SQL语法错误 SELECT artists.name, albums.title, genres.genre FROM artist_album JOIN artists ON artist_album.artist_id = artists.id JOIN albums ON artist_album.album_id = albums.album_id FROM album_genre JO

我在下面代码的“第5行”附近遇到一个SQL语法错误

SELECT artists.name, albums.title, genres.genre
    FROM artist_album
        JOIN artists ON artist_album.artist_id = artists.id
        JOIN albums ON artist_album.album_id = albums.album_id
    FROM album_genre
        JOIN genres ON album_genre.genre_id = genres.genre_id
        WHERE genres.genre = 'Pop' OR genres.genre = 'Rock'
我想找到的是数据库中所有发行“摇滚”或“流行”专辑的艺术家。查询应返回艺术家姓名、专辑标题和专辑类型

我的桌子是:

albums
    album_id
    released
    title

artist
    id
    name

genres
    genre_id
    genre

album_genre
    album_id
    genre_id

artist_album
   album_id
   artist_id
我对SQL非常陌生,所以我确信我做错了什么是我不知道的。。但在互联网上搜寻了一段时间后,我看不出我在语法上可能做错了什么


如有任何帮助/建议,将不胜感激,谢谢

看起来应该是这样

JOIN album_genre ON album_genre.album_id = albums.album_id
而不是

FROM album_genre
这是您的SQL:

SELECT artists.name, albums.title, genres.genre
From artists join artist_album On artist_album.artist_id = artists.id
join albums ON artist_album.album_id = albums.album_id
join album_genre ON album_genre.album_id =albums.album_id
JOIN genres ON album_genre.genre_id = genres.genre_id
        WHERE genres.genre = 'Pop' OR genres.genre = 'Rock'

你有两个“来自”的…那个。。实际上很有道理。。我不知道我在想什么:|谢谢杰森!