I have 2 tables:
A B
-- ----
ID FKID
-- ----
1 3
2 3
3 4
4 4
I need a select statement which shows me all of A with a field that tells me if table B has any ids that match that ID.
Desired Result
-----------
ID | hasB
-----------
1 no
2 no
3 yes
4 yes
In SQL Server this would be the most efficient way rather than doing an
OUTER JOINthen removing the duplicates withDISTINCT. Not sure for postgres, you’d need to check the plans.