sql - Select COUNT in two table in one query with MYSQL -
is there way can select count 2 table 1 single query.
at moment have following , doesn't work correctly.
select count(t1.id) t1_amount, count(t2.id) t2_amount table1 t1, table2 t2
here 1 way:
select (select count(*) table1) t1_amount, (select count(*) table2) t2_amount
here way:
select t1.t1_amount, t2.t2_amount (select count(*) t1_amount table1) t1 cross join (select count(*) t2_amount table2) t2
your method not work because ,
in from
clause cross join
. cartesian product between 2 tables.
Comments
Post a Comment