大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

sqlserver联合查询,hql 联合查询

请教大神SQlSERVER向这样多表联合查询怎么写语句

SELECT s.*,p.player_name FROM t_match_score s

创新互联主要从事做网站、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务克拉玛依,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

LEFT JOIN t_match_player p

ON s.player_id=p.player_id

sqlserver多表联合查询

select c.discount

from a,b,c where a.hw_name=b.hw_name

and b.sort_id=c.sort_id

and a.hw_name='苹果'

“sqlserver”三表联如何查询“sql”语句?

假设学生表叫student,课程表叫class,选课表叫choose\x0d\x0a1.三层嵌套的问题\x0d\x0aselect student.name from student where student.id IN\x0d\x0a (select choose.sid from choose where choose.cid NOT IN\x0d\x0a (select class.id from class where class.teacher='李明'))\x0d\x0a2.一个内连接,一个嵌套\x0d\x0aselect student.name,avg(choose.score) from\x0d\x0astudent inner join choose on student.id=choose.sid\x0d\x0awhere student.id IN\x0d\x0a (select choose.sid from choose \x0d\x0a where choose.score=2)\x0d\x0agruop by student.id\x0d\x0a3.一个联合查询,一个嵌套查询\x0d\x0aselect student.name from student\x0d\x0awhere student.id IN\x0d\x0a(select c1.sid from choose c1 where choose.cid='1'\x0d\x0a union \x0d\x0a select c2.sid from choose c2 where choose.cid='2'\x0d\x0a on c1.sid=c2.sid\x0d\x0a)\x0d\x0a4.其实就是自连接查询和行列交换的问题:\x0d\x0aselect student.id,\x0d\x0a(case choose.id when '1' then choose.score end) as 1号课成绩,\x0d\x0a(case choose.id when '2' then choose.score end) as 2号课成绩,\x0d\x0afrom student inner join choose on student.id=choose.sid sc1,\x0d\x0astudent inner join choose on student.id=choose.sid sc2\x0d\x0awhere sc1.id='1' \x0d\x0aand sc2.id='2'\x0d\x0aand sc1.scoresc2.score


本文名称:sqlserver联合查询,hql 联合查询
本文链接:http://dzwzjz.com/article/phjccd.html
在线咨询
服务热线
服务热线:028-86922220
TOP