我正在尝试使用子查询插入数据。我只会在下面发布我的SELECT
声明。
SELECT PlaylistCode
FROM Playlists
WHERE Name_Of_Playlist = 'X'
AND
(SELECT Code
FROM Songs
INNER JOIN Artists ON Artists.PageURL = Songs.PageURL
WHERE Artist = 'X'
LIMIT 200)
错误代码:1242。子查询返回的行多于0.016秒
答案 0 :(得分:1)
尝试以下查询
SELECT PlaylistCode
FROM Playlists
WHERE exits
(SELECT Code
FROM Songs
INNER JOIN Artists ON Artists.PageURL = Songs.PageURL
WHERE Artist = 'X'
LIMIT 200) and Name_Of_Playlist = 'X'
答案 1 :(得分:0)
根据您的要求,您需要先使用select case
然后使用join
相应的表
INSERT INTO Playlists (PlaylistCode)
SELECT CASE WHEN a.Artist = 'X' THEN 'X' ELSE s.Code END
FROM Songs s
INNER JOIN Artists a ON a.PageURL = s.PageURL