1樓:
select distinct t.學號
from (select distinct 表名.學號
from表名 ,表名 t2
where表名.課程號=1 and t2.課程號=2 and 表名.學號=t2.學號) t
where t.學號 not in(select distinct 表名.學號
from表名,
(select distinct 表名.學號
from表名 ,表名 t2
where表名.課程號=1 and t2.課程號=2 and 表名.學號=t2.學號) t
where t.學號=表名.學號 and表名.課程號<>1 and 表名.課程號<>2)
sql查詢沒有同時選修1號課程和2號課程學生的學號
2樓:匿名使用者
select distinct sno
from sc
where sno not in
(select sno
from sc
where cno='1' and sno in(select sno
from sc
where cno='5'))
這是一般的變法,還可用集合查詢,關鍵字intersectselect distinct sno
from sc
where sno not in
(select sno
from sc
where cno='1'
intersect
select sno
from sc
where cno='5')
3樓:匿名使用者
select s.學號
from student s,course c,sc scwhere s.學號=sc.學號 and c.課程號=sc.課程號 and
c.課程號='1'
union
select s.學號
from student s,course c,sc scwhere s.學號=sc.學號 and c.課程號=sc.課程號 and
c.課程號='2'
4樓:凌動小生
select distinct sc.sno where sc.cno !='課程1'and sc.cno !='課程2'
5樓:匿名使用者
select sno where [sc] cno='選修1號' and cno='選修2號' order by sno
用sql查詢同時選修了1號課和2號課的學生學號
6樓:於曉楠買甘
查詢bai
同時選修了1號和2號課的學du生學號
涉及到兩zhi個表.學生表和dao課程表
語句:select
*from
student
inner
join
scon
student.sno=sc.sno
andcno
in('1','2')
為什麼不用內where
cno=’1‘
andcno=’2‘
這個關係到資料容庫的優化問題,哪個執行快,就寫哪個那個語句也可以這樣寫啊where
snoin
(select
snofrom
scwhere
sno=’1‘
)and
snoin(select
snofrom
scwhere
sno=’2‘)
7樓:吳
你好抄像寫錯了吧,襲
,,我感覺應該是bai
select sno
from sc
where cno='1' and son in (select sno from sc where cno='2');
或者where cno='1' intersert select sno from sc where cno='2');
intersect對兩個du查詢zhi做交集。相當於daoand
8樓:envy誒
因為這樣的意思是 在一行內課號既得等於1又得等於2 並沒有這樣的
9樓:匿名使用者
sno 指的是什麼?
baicno指什麼? 上面的sql語句du是不可能zhi實現同樣的功能的。
sno如果是指dao學生學號;版
cno是指課程號的權
話。where cno=’1‘ and cno=’2‘是指課程號是1和2 的學生資訊。
where sno=’1‘ and sno in(select sno
from sc
where sno=’2‘)
是指學生學號是1和2 的學生,事實上,作為主鍵的sno沒有可能同時是1和2的。
請採納答案,支援我一下。
sql求選修了1號課或2號課的學生學號和課號及成績用集合查詢的方法
10樓:隨緣_莫隨緣
select sno
from sc
where cno='1'
intersect
select sno
from sc
where cno='2'
集合運算,列的數目、型別要一致
如果還報錯,那就考慮別的語法吧,not in或者not exists列值不一樣的記錄,在集合想減時減不掉,所以要把cno和grade列去掉
11樓:鹹菜學徒
select sno,cno,grade
from sc
where cno='1'
or cno='2'
資料庫sql查詢同時選修了選修課1和選修課2的學生學號
練習一:對學生—課程資料庫進行以下查詢,按要求寫出關係代數和sql語句. 1. 查詢全體學生的學號和姓名. .
12樓:匿名使用者
對照你的表名,表中欄位名修改
13樓:匿名使用者
你得提供表名稱,欄位 啊
sql查詢沒有選修1號課程的學生姓名
14樓:匿名使用者
select sname
from student
where not exists
(select *
from sc
where student.sno=sc.sno and cno='1');
15樓:匿名使用者
select [姓名(sname)] from student where not exists (select *
16樓:匿名使用者
from sc where sno=student.[學號(sno)] and cno='1');
大雅柑橘,大雅1號2號柑橘和愛媛38號哪個更好
目前大雅柑比較成熟的品種是大雅1號,其實不管是大雅柑還是愛媛38號,都有其優劣勢,不過目前大雅柑處於不上不下的地位,現在很少人種植大雅了,要不種植成熟的春見,要不種植春見的升級版明日見,而作為曾經春見的改良版大雅已經鮮有人提及。所以,在早熟品種裡,愛媛38號是目前當之無愧的優質品種,大雅就不是很建議...
北京地鐵1號線和2號線的末班時間
1號線列車時刻表 車站名稱 蘋果園 四惠東 四惠東 蘋果園 首車時刻 末車時刻 首車時刻 末車時刻 蘋果園 5 10 22 55 5 40 0 11 古城路 4 58 22 59 5 35 0 06 八角遊樂園 5 01 23 02 5 32 0 03 八寶山 5 04 23 05 5 29 0 0...
什麼叫做1號病和2號病,主要症狀是
鼠疫 俗稱1號病 是指由鼠疫桿菌引起的自然疫源性烈性傳染病。主要症狀 突發高燒,伴有顏面潮紅,結膜充血,噁心嘔吐,頭及四肢疼痛,黏膜出血,繼而可出現意識模糊,言語不清,步態蹣跚,衰竭和血壓下降等。霍亂 俗稱2號病 是指由霍亂弧菌引起的烈性腸道傳染病。主要症狀 腹瀉和嘔吐,繼而出現脫水及電解質紊亂,嚴...