Ron-279530
Ten Centuries
Points: 1381
More actions
May 10, 2007 at 8:54 pm
#124045
How can I combine this into one query?
select count(*) from table1 a
left join table2 b on a.id = b.id
where a.field1 = 1
and a.field2 = 2
select count(*) from table2 b
left join table1 a on a.id = b.id
Sergiy
SSC Guru
Points: 110208
May 10, 2007 at 10:43 pm
#705713
Condition
makes all rows from table1 mandatory, so LEFT JOIN from second query does not work.
Not sure what do you really mean but probably it must be like this:
select count(*)
from table2 b
FULL OUTER join table1 a on a.id = b.id AND a.field1 = 1 and a.field2 = 2
_____________Code for TallyGenerator
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply