怎麼用sql語句查詢學生沒有選的課

2021-03-21 16:26:44 字數 5146 閱讀 9935

1樓:匿名使用者

select c_name from course where c_id not in

(select c_id from choice where sid in

(select sid from stu where name='張三')

)把張三換成你要查的人就好了

2樓:匿名使用者

with stu as(

select 1 sid,'li' name from dual union all

select 2,'wang' from dual union all

select 3,'liu' from dual union all

select 4,'hong' from dual union all

select 5,'song' from dual),

course as(

select 1 c_id,'c1' c_name from dual union all

select 2 c_id,'c2' c_name from dual union all

select 3 c_id,'c3' c_name from dual union all

select 4 c_id,'c4' c_name from dual ),

choice as(

select 1 sid,1 c_id from dual union all

select 1,2 from dual union all

select 4,1 from dual union all

select 2,3 from dual )

select stu.name,c_name from

stu,course,choice

where stu.sid!=choice.sid

and choice.c_id=course.c_id;

3樓:匿名使用者

select stu.name,course.*from stu,course,choicewhere

stu.sid=choice.sid

andcourse.c_id=choice.c_idgo希望幫到你

資料庫中,用sql語言如何查詢沒有選修1號課程的學生姓名

4樓:哈皮的小逗比

student--學生表

student_id,

student_name,

student_no

course--課程表

course_id,

course_name

sc--選課資訊表

student_id,

course_id

select *

from student

where student_id not in(select student_id

from sc

where course_id in

(select course_id from course where course_name = '1號課程'))

5樓:冉涵陽翁雋

假設學生表為a,學號欄位為id,姓名欄位為name;

課程表為b,其中row_id為課程編號,stu_no為選修該門課的學生的學號

sql:

select

a.id,a.name

from

awhere

a.id

notin

(select

distinct

b.stu_no

fromb)

6樓:匿名使用者

select sname

from student

where not exists

(select *

from sc

where student.sno=sc.sno and **o='1');

要查詢選修了所有課程的學生資訊,怎樣用sql實現

7樓:闕黴錘

第一問:兩個復not exists表示雙制重否定:沒有一個選了課的學生沒有選course表裡的課程

select sname

from student

where not exists /*沒有一個學生滿足以下條件*/

(select * from course

where not exists /*什麼條件呢?沒有選過course表裡的課*/

(select * from sc

where sno =student.sno /*這裡兩個=分別指對應的關係,表示選過課並且是course裡and **o=course.**o) 的課,只不過用not exists否定掉了*/

第二問:其實和not in 是一個意思 exists只返回true 或false 這裡not exists裡的內容 其實就是指學生選過的課程,再用not exists否定了,就變成了沒有選的

sql查詢全部課程選修的學生姓名,怎麼得出某同學沒有選課?

8樓:匿名使用者

分析原因如下:

第一問:兩個not exists表示雙重否定:沒有一個選了課的學生沒有選course表裡的課程

select sname from student   where not exists /*沒有一個學生滿足以下條件*/

(select *   from course  where not exists  /*什麼條件呢?沒有選過course表裡的課*/

(select *  from sc  where sno =student.sno   /*這裡兩個=分別指對應的關係,表示選

過課並且是course裡and **o=course.**o)  的課,只不過用not exists否定掉了*/

第二問:其實和not in 是一個意思 exists只返回true 或false 這裡not exists裡的內容 其實就                     是指學生選過的課程,再用not exists否定了,就變成了沒有選

怎麼用sql語句查詢每個學生選修的課程名及其成績?

9樓:消逝的風

select 姓名,課程名,成績 from (課程名所在的表名 c join 成績所在的表名 s on c.課程號=s.課程號) join 學生資訊表 on s.

學號=學生資訊表.學號 ;

具體的例子:

select sname,**ame,grade from student st left join(score s left join course c on s.**o=c.**o)

on st.sno=s.sno;

10樓:趙星宇

查詢選修了全部課程的學生姓名

:student 是學生表  course 是選課表  sc 是課程表

select sname

from student

where not exists

(select *

from course

where not exists

(select *

from sc

where sno =student.snoand **o=course.**o)

使用sql語句刪除沒有學生選修的課程記錄

11樓:匿名使用者

delete from 課程 where 課程號 not in(select 課程號 from 選課)

12樓:匿名使用者

delete 課程 where 課程號 in(select 課程號 from 選課 a where not exists (select 學號 from學生 where a.學號=學號))

如此即可

sql查詢沒有選修1號課程的學生姓名

13樓:匿名使用者

select sname

from student

where not exists

(select *

from sc

where student.sno=sc.sno and **o='1');

14樓:匿名使用者

select [姓名(sname)] from student where not exists (select *

15樓:匿名使用者

from sc where sno=student.[學號(sno)] and **o='1');

求用sql語言在資料庫中查詢沒有選修任何課程的學生的學號,姓名的命令?

16樓:匿名使用者

假設學生表為

a,學號欄位為id,姓名欄位為name;

課程表為b,其中row_id為課程編號,stu_no為選修該門課的學生的學號

sql:

select a.id,a.name

from a

where a.id not in (select distinct b.stu_no from b)

17樓:匿名使用者

應為三張表:

學生表a 課程表b 選修表c(cid aid bid)--沒有選修任何課程的學生的學號

select * from a where aid not in(select distinct aid from c) --為已選修的人

如有問題可以追問,我當及時回答.

希望能幫到你!

18樓:抽插小旋風

select 學號,姓名 from 表 where 選修課程 is null

或者select 學號,姓名 from 表 where 選修課程 =『』

試用sql查詢語句表達學生,試用SQL查詢語句表達學生 課程資料庫中3個基本表S,SC,C的查詢

你提供bai的資訊du 不全,從zhi 第三題開 dao始沒辦法作內 答了。容。create table sc sno int not null,cno nvarchar 50 not null,grade nvarchar 50 not null goselect from course wher...

用SQL查詢語句怎麼讓表中ID按照順序來

這個首先你要寫出你要查詢的內容,如 select name,age from student order by id asc asc 代表升序這也是預設的desc代表降序 select row number over order by id asc as rowno from 表 降序 order ...

sql語句中在學生資訊表中查詢同姓的學生姓名

1 建立一個測試表bai 如下du圖 createtabletest name idint,namevarchar2 20 zhi 2 插入測試資料dao 如下圖專 insertintotest namevalues 102,李三 insertintotest namevalues 103,陳五 i...