Maison >développement back-end >tutoriel php >问个连表的MYSQL查询语句
假如
表1
id name
1 A
2 B
表2
id money
1 10
1 15
2 20
1 10
如何用左链表的方式,获得如下结果呢
1 A 40
2 B 20
select a.*, sum(money) as money from 表1 a left join 表2 b on a.id=b.id
1 A 45
2 B 20
select a.*, sum(money) as money from 表1 a left join 表2 b on a.id=b.id
1 A 45
2 B 20
select a.*, sum(money) as money from 表1 a left join 表2 b on a.id=b.id
1 A 45
2 B 20