join query in mysql -
i having table structure
table1 table2 pid pname pid uid cat 1 1 1 1 2 b 1 2 1 3 c 1 3 1 select * table1 t1 left join table2 t2 on t1.pid=t2.pid t2.uid=1 , t2.cat=1
it's select 2 rows
i don't want group pid because may have same pid in table 1 need number of rows matched pid
this may silly question tried hard couldn't .
i hope people can me!
thanks in advance
if want count of rows match:
select count(*) table1 t1 inner join table2 t2 on t1.pid = t2.pid t2.uid=1
your left join unnecessary, since filtering table2.
Comments
Post a Comment