如何在mysql中加入表

时间:2015-09-13 12:14:57

标签: sql oracle

我的要求是:

select (*ALL columns of table1, [count of rows of TABLE2 where TABLE1.id  = Table2.id] 
from TABLE1, TABLE2 
where TABLE1.status = 'A'

现在是SQL,如果问题太简单,请原谅

2 个答案:

答案 0 :(得分:2)

select t1.col1, t1.col2, t1.col3, count(t2.id)
from table1 t1
left join TABLE2 t2 on t1.id  = t2.id
where t1.status = 'A'
group by t1.col1, t1.col2, t1.col3

答案 1 :(得分:1)

使用相关子查询:

globals