Distinct left join
Hello,
I'm having a bit of head-block on this.
I have 2 tables a and b where a.id is in b 0, 1 or many times.
All I'm wondering is if there is a more efficient way of saying
SELECT DISTINCT a.*, b.a_id
FROM a
LEFT JOIN b ON b.a_id = a.id
given that a is really a complex sql statement on its own.
All I really want is a column which says whether a.id exists in b but which is the most efficient way of doing it,
Regards,
Iain