怎么样用SQL语句查询某一个表里面的某一个字段的总和?

如题所述

模板:

1、“select s.id,s.name,t.id,t.name from student  s  left join teacher t on t.id=s.teacher_id;”

2、“select s.id as student_id ,s.name as student_name,t.id as teacher_id,t.name as teacher_name from student  s  left join teacher t on t.id=s.teacher_id;”

另外,查询一个表中某个字段相同的数据的方法:

也是拿student来做例子,查询有相同老师的student。

“select * from students group by teacher_id HAVING COUNT(teacher_id)>1;”

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答