怎么样用SQL语句查询某一个表里面的某一个字段的总和?
1个回答
展开全部
模板:
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;”
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询