具體要查哪個(gè)字段,你自己修改吧,我?guī)湍惆驯碇g的鏈接條件寫出來。
成都創(chuàng)新互聯(lián)公司服務(wù)項(xiàng)目包括青田網(wǎng)站建設(shè)、青田網(wǎng)站制作、青田網(wǎng)頁制作以及青田網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,青田網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到青田省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
select a.*, b.*, c.* from a, b, c where a.a1 = b.b1 and a.a2 = c.c2 and a2 = an
解決方案
既然知道了問題所在,那么久好解決了。找到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ù),如果停止,則無法提供SQL SERVER服務(wù)。"
NET START mssqlserver
注意:以上代碼中路徑部分,請(qǐng)修改為本機(jī)Sqlserver安裝路徑。
假設(shè)學(xué)生表叫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.一個(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í)就是自連接查詢和行列交換的問題:
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