Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Union query in sub query

$
0
0
HI
i have a UNION query that returns the names and ID's of students in likes table, (likes.id1 & likes.id2.
i want to subtract this from the students in another table (highschooler) to find the missing students not in the likes table.
whater i do in the code i keep getting this error message, "this operation is not allowed in subqueries"anmybody any clues how to get round this?

COde is:-

SELECT Highschooler.name, Highschooler.id
FROM Highschooler
WHERE highschooler NOT IN

(SELECT DISTINCT highschooler.id
FROM highschooler RIGHT JOIN likes ON highschooler.ID = likes.ID1
WHERE likes.id1 = highschooler.id

UNION

SELECT highschooler.id
FROM highschooler INNER JOIN likes ON highschooler.ID = likes.ID2
WHERE highschooler.id = likes.id2);

Viewing all articles
Browse latest Browse all 13329

Trending Articles