> > And postgres tries to be helpful again... :( [I *really* dislike this
> > adding to from list thing] Technically the above should be illegal
> > because no from list contains u or a. Postgres is adding them to the
> > from list for you.
> >
> I get the same result if I do:
> select count(d.id) from d where status = 2 and d.id = u.dkey and
> u.status = 2 and not u.b and u.akey = a.key and a.status = 3;
>
> So in standard SQL all the tables you join accross are required to be in
> the FROM?
Basically, yes. It's more complicated than that probably (what isn't in
SQL), but that's the general idea.
Postgres assumes your query is
select count(*) from d,u,a ...
Because d.id was guaranteed to be unique, you might be able to
count(distinct d.id) and get the result you want. [I think the
subquery is a nicer way of representing it]