比如有三张表,student,teacher , project :
第一种方法:select * from student,teacher,project where student.id=teacher.sid and student.id=project.sid;
第二种:select * from student inner join teacher on student.id=teacher.sid inner join project on student.id=project.sid;
项目中的例子:
from (SELECT [name],sum(number) as totalnumber FROM [collect] WHERE [recordtime] BETWEEN 1480521600 AND 1481696201 AND collect.display = '1'
GROUP BY name) a
FULL JOIN (SELECT [name],sum(number) as lasttotalnumber FROM [collect]
WHERE [recordtime] BETWEEN 1477929600 AND 1480521600 AND collect.display = '1' GROUP BY name) b on a.name=b.name
FULL JOIN (SELECT [name],sum(number) as totaladd FROM [addcollect]
WHERE [recordtime] BETWEEN 1480521600 AND 1481696201 AND addcollect.display = '1' GROUP BY name) c on a.name=c.name```
![结果](http://upload-images.jianshu.io/upload_images/2926249-d89cec848d2492f4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)