十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
解决方案
成都创新互联公司专注于盘山企业网站建设,成都响应式网站建设公司,成都做商城网站。盘山网站建设公司,为盘山等地区提供建站服务。全流程定制网站,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务
既然知道了问题所在,那么久好解决了。找到SQL SERVER安装路径,Binn目录下,找到这个文件:
右键用超级管理员账户运行,就可以发现Sql server提供服务了!
sqlserverstart
虽然运行成功了,但是总不能每次去运行吧。所以我再写一段批处理,保存为bat文件运行即可。批处理内容:
@echo off
SC CREATE mssqlserver binPath= "D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" DisplayName= "SQL Server" start= auto
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mssqlserver /v Description /t REG_SZ /d "用于提供SQL SERVER服务的服务,如果停止,则无法提供SQL SERVER服务。"
NET START mssqlserver
注意:以上代码中路径部分,请修改为本机Sqlserver安装路径。
假设学生表叫student,课程表叫class,选课表叫choose
1.三层嵌套的问题
select student.name from student where student.id IN
(select choose.sid from choose where choose.cid NOT IN
(select class.id from class where class.teacher='李明'))
2.一个内连接,一个嵌套
select student.name,avg(choose.score) from
student inner join choose on student.id=choose.sid
where student.id IN
(select choose.sid from choose
where choose.score'60'
group by choose.sid
having count(choose.sid)=2)
gruop by student.id
3.一个联合查询,一个嵌套查询
select student.name from student
where student.id IN
(select c1.sid from choose c1 where choose.cid='1'
union
select c2.sid from choose c2 where choose.cid='2'
on c1.sid=c2.sid
)
4.其实就是自连接查询和行列交换的问题:
select student.id,
(case choose.id when '1' then choose.score end) as 1号课成绩,
(case choose.id when '2' then choose.score end) as 2号课成绩,
from student inner join choose on student.id=choose.sid sc1,
student inner join choose on student.id=choose.sid sc2
where sc1.id='1'
and sc2.id='2'
and sc1.scoresc2.score
具体要查哪个字段,你自己修改吧,我帮你把表之间的链接条件写出来。
select a.*, b.*, c.* from a, b, c where a.a1 = b.b1 and a.a2 = c.c2 and a2 = an