Help combining query

  • 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

    where a.field1 = 1

    and a.field2 = 2

  • Condition

    where a.field1 = 1

    and a.field2 = 2

    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