Home > Backend Development > PHP Tutorial > 问一个关于MYSQL链表的有关问题

问一个关于MYSQL链表的有关问题

WBOY
Release: 2016-06-13 12:13:03
Original
837 people have browsed it

问一个关于MYSQL链表的问题
a1 

a2

a3


三个表现在我的写法是 
select a1.*,sum(a2.money) as money from a1 left join a2 on a1.id=a2.id left join a3 on a2.no = a3.no group by a1.id ;
得出的结果是


出于其它因素必须要连接a3表,导致了money为35,我想要的是money为25,应该怎么写?
------解决思路----------------------
a3.no 不唯一,导致 a2.no=a3.no 时 a2 的 (11 1 10.00)出现两次
所以你需对 a3 加约束条件
 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template