我现在有两个表样把两个连起来。
第一个表格是:
month value
11-01 4
12-01 6
01-01 10
第一个表格是用select写的 select month, value from table1
第2个表格是
month name selected
11-01 bus 10
11-01 car 8
12-01 auto 9
01-01 book 12
12-01 tea 10
第2个表格是用select写的 select month, name, sum(function.seleced) as selected from table 2 group by name
两个表格由日期连接,最终的结果是
month name selected value
11-01 bus 10 4
11-01 car 8 4
12-01 auto 9 6
01-01 book 12 10
12-01 tea 10 6谢谢大家
第一个表格是:
month value
11-01 4
12-01 6
01-01 10
第一个表格是用select写的 select month, value from table1
第2个表格是
month name selected
11-01 bus 10
11-01 car 8
12-01 auto 9
01-01 book 12
12-01 tea 10
第2个表格是用select写的 select month, name, sum(function.seleced) as selected from table 2 group by name
两个表格由日期连接,最终的结果是
month name selected value
11-01 bus 10 4
11-01 car 8 4
12-01 auto 9 6
01-01 book 12 10
12-01 tea 10 6谢谢大家
select month, name, sum(function.seleced) as selected from table 2 group by name) A
LEFT JOIN
(select month, value from table1 ) B
ON A.`month`=B.`month`
(select month,name,sum(function.selected)as selected from table2 group by name)A
left join
(select month,value from table1)B
ON A.month=B.month;