INSERT INTO People(Track_id_Reference)
SELECT track_id
FROM Tracks
WHERE track_title IN (SELECT tracktitle
FROM top100
WHERE artist IN (SELECT p.People_name, t.artist
FROM People AS p
RIGHT JOIN top100 AS t
ON
p.People_name=t.artist
UNION DISTINCT
SELECT p.People_name, t.artist
FROM People AS p
LEFT JOIN top100 AS t
ON
p.People_name=t.artist));
The error I get is
ERROR 1241 (21000): Operand should contain 1 column(s)
subquery which unions returns 2 columns. How can I fix this?
you lack
FROMclauseso the full query would be
another problem that will arise soon is the use of equal
=sign on the result of the subquery, it is much safer to useINthan=because it will throw an exception if, for instance, the subquery will return more than one value. Example,