解決方案
成都創(chuàng)新互聯(lián)公司專注于盤山企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,成都做商城網(wǎng)站。盤山網(wǎng)站建設(shè)公司,為盤山等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)
既然知道了問(wèn)題所在,那么久好解決了。找到SQL SERVER安裝路徑,Binn目錄下,找到這個(gè)文件:
右鍵用超級(jí)管理員賬戶運(yùn)行,就可以發(fā)現(xiàn)Sql server提供服務(wù)了!
sqlserverstart
雖然運(yùn)行成功了,但是總不能每次去運(yùn)行吧。所以我再寫一段批處理,保存為bat文件運(yùn)行即可。批處理內(nèi)容:
@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服務(wù)的服務(wù),如果停止,則無(wú)法提供SQL SERVER服務(wù)。"
NET START mssqlserver
注意:以上代碼中路徑部分,請(qǐng)修改為本機(jī)Sqlserver安裝路徑。
假設(shè)學(xué)生表叫student,課程表叫class,選課表叫choose
1.三層嵌套的問(wèn)題
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.一個(gè)內(nèi)連接,一個(gè)嵌套
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.一個(gè)聯(lián)合查詢,一個(gè)嵌套查詢
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.其實(shí)就是自連接查詢和行列交換的問(wèn)題:
select student.id,
(case choose.id when '1' then choose.score end) as 1號(hào)課成績(jī),
(case choose.id when '2' then choose.score end) as 2號(hào)課成績(jī),
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
具體要查哪個(gè)字段,你自己修改吧,我?guī)湍惆驯碇g的鏈接條件寫出來(lái)。
select a.*, b.*, c.* from a, b, c where a.a1 = b.b1 and a.a2 = c.c2 and a2 = an