Sample Header Ad - 728x90

Howto combine UNION with EXISTS?

5 votes
2 answers
17409 views
I have a query that looks like this: SELECT PubKey, Title FROM Publication UNION SELECT NoteKey, Title, FROM Note Which works fine. My trouble start when I try to add an EXIST to it: SELECT PubKey, Title FROM Publication UNION SELECT NoteKey, Title, FROM Note WHERE EXISTS (SELECT * FROM UserPublication WHERE UserPublication.PubKey = Publication.PubKey) That throws this error: The multi-part identifier "PubKey" could not be bound. Could it be written another way?
Asked by Bjørn Fridal (65 rep)
Feb 1, 2016, 10:57 PM
Last activity: Mar 24, 2021, 02:35 AM