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?