当前位置: 代码迷 >> SQL >> 最长的SQL话语
  详细解决方案

最长的SQL话语

热度:38   发布时间:2016-05-05 13:44:32.0
最长的SQL语句

今天无意之中,我竟然写出我目前写得最长的一条SQL语句:

select m.stu_Name stuName,
(select soureNumber from studentSoure where subjectid='1' and stu_id='20081030001' and classID='18') '期中英语',
(select soureNumber from studentSoure where subjectid='2' and stu_id='20081030001' and classID='18') '期中语文',
(select soureNumber from studentSoure where subjectid='3' and stu_id='20081030001' and classID='18') '期中数学',
(select soureNumber from studentSoure where subjectid='4' and stu_id='20081030001' and classID='18') '期中政治',
(select soureNumber from studentSoure where subjectid='5' and stu_id='20081030001' and classID='18') '期中历史',
(select soureNumber from studentSoure where subjectid='6' and stu_id='20081030001' and classID='18') '期中地理',
(select soureNumber from studentSoure where subjectid='7' and stu_id='20081030001' and classID='18') '期中生物',
(select soureNumber from studentSoure where subjectid='8' and stu_id='20081030001' and classID='18') '期中化学',
(select soureNumber from studentSoure where subjectid='9' and stu_id='20081030001' and classID='18') '期中物理',
(select soureNumber from studentSoure where subjectid='10' and stu_id='20081030001' and classID='18') '期中体育',
(select soureNumber from studentSoure where subjectid='11' and stu_id='20081030001' and classID='18') '期中班级排名',
(select soureNumber from studentSoure where subjectid='12' and stu_id='20081030001' and classID='18') '期中年级排名',
(select soureNumber from studentSoure where subjectid='13' and stu_id='20081030001' and classID='18') '期末英语',
(select soureNumber from studentSoure where subjectid='14' and stu_id='20081030001' and classID='18') '期末语文',
(select soureNumber from studentSoure where subjectid='15' and stu_id='20081030001' and classID='18') '期末数学',
(select soureNumber from studentSoure where subjectid='16' and stu_id='20081030001' and classID='18') '期末政治',
(select soureNumber from studentSoure where subjectid='17' and stu_id='20081030001' and classID='18') '期末历史',
(select soureNumber from studentSoure where subjectid='18' and stu_id='20081030001' and classID='18') '期末地理',
(select soureNumber from studentSoure where subjectid='19' and stu_id='20081030001' and classID='18') '期末生物',
(select soureNumber from studentSoure where subjectid='20' and stu_id='20081030001' and classID='18') '期末化学',
(select soureNumber from studentSoure where subjectid='21' and stu_id='20081030001' and classID='18') '期末物理',
(select soureNumber from studentSoure where subjectid='22' and stu_id='20081030001' and classID='18') '期末体育',
(select soureNumber from studentSoure where subjectid='23' and stu_id='20081030001' and classID='18') '期末班级排名',
(select soureNumber from studentSoure where subjectid='24' and stu_id='20081030001' and classID='18') '期末年级排名',
(select soureNumber from studentSoure where subjectid='25' and stu_id='20081030001' and classID='18') '同桌',
(select soureNumber from studentSoure where subjectid='26' and stu_id='20081030001' and classID='18') '组长',
(select soureNumber from studentSoure where subjectid='27' and stu_id='20081030001' and classID='18') '班长',
(select soureNumber from studentSoure where subjectid='28' and stu_id='20081030001' and classID='18') '语文课代表',
(select soureNumber from studentSoure where subjectid='29' and stu_id='20081030001' and classID='18') '英语课代表',
(select soureNumber from studentSoure where subjectid='30' and stu_id='20081030001' and classID='18') '数学课代表',
(select soureNumber from studentSoure where subjectid='31' and stu_id='20081030001' and classID='18') '仪容仪表情况',
(select soureNumber from studentSoure where subjectid='32' and stu_id='20081030001' and classID='18') '作业缴纳情况',
(select soureNumber from studentSoure where subjectid='33' and stu_id='20081030001' and classID='18') '值日卫生情况',
(select soureNumber from studentSoure where subjectid='34' and stu_id='20081030001' and classID='18') '考勤情况(含早操)',
(select soureNumber from studentSoure where subjectid='35' and stu_id='20081030001' and classID='18') '午休检查情况',
(select soureNumber from studentSoure where subjectid='36' and stu_id='20081030001' and classID='18') '何时何地受奖励(处分)',
(select soureNumber from studentSoure where subjectid='37' and stu_id='20081030001' and classID='18') '班主任谈话情况(与家长)'
from studentSoure o inner join studentMa m on o.stu_id=m.stu_id
where m.stu_id='20081030001' and m.classID='18' group by m.stu_Name

这是我帮同学写的一条SQL,由于所有数据都保存在一张表里,但打印时又一列打印出来。

真是累死我了!

  相关解决方案