Frank Joerdens <frank(at)joerdens(dot)de> writes:
> This works fine if there is *at least* one row in B for each row in A.
> If there isn't, I obviously get 0 results even if the column foo in A
> matches the desired criteria. But I do want the rows from A even if
> there is no row in B that is linked to those rows in A that match the
> criteria.
You want an "outer join". Something like
FROM A LEFT JOIN B ON (A.id = B.a_id)
WHERE [other criteria]
regards, tom lane