SQL語言1 查詢每個學生及其選修課程的情況查詢所有年齡

2021-03-26 12:53:11 字數 3892 閱讀 5171

1樓:匿名使用者

(1) select t.sname,c.cpno fromstudent t

left join sc s (s.sno=t.sno)left join course c (c.

**o=s.**o)(2) select t.sno,t.

sname from student t

where t.s***='女' and t.sage <18不行了在找我,可以密我**。

2樓:匿名使用者

1 select student.sno, sc.**ofrom student,sc

where student.sno = sc.**o;

意思就是查詢每個學生的情況,且列出相應的選修情況2 select student.s***, student.sage

from student

where student.sage<18 and student.s***=2;

's***=2意思就是等於女的意思,一般在這個表裡s***字段設定為數字型1為男2為女,也可以設定成字元型,但不如數字型使用方便

3樓:真愛的胸懷

select sno,sname,from student where (sage<18 and s***='女')

以上是第二個語句的答案 ,第乙個語句有歧義

4樓:匿名使用者

select a.sno,a.sname,b.**amefrom student a,cours b,sc cwhere a.sno=c.sno

and b.**o=c.**o

group by a.sno,a.sname,b.**ameselect sno,sname from studentwhere s***='女' and sage<18

請幫忙寫出下列sql語句的步驟: 1.查詢成績表的所有成績 2.查詢學生的學號,姓名和年齡 (接著在下面)

5樓:楓啦啦

你表的字段和表的關係都沒給....

只能認為表裡面有所有的字段了...

1 select * from 成績表

2 select 學號,姓名,年齡 from 學生資訊表

3 select 學號,姓名,課程名,成績 from 選課表

4 select * from 學生資訊表 where 姓名 like '張%'

5 select top 4 * from 學生資訊表 where 學號 like '9952%'

6 select count(*) as 男生人數 from 學生資訊表 where 性別='男'

7 select * form 學生資訊表 where 性別='女' and 黨員='是'

8 select 學號 from 成績表 where 成績》80 and 成績<90

9 select 學號,姓名 from 成績表 where 成績<60

ps:這題,如果姓名不在成績表中的話應該是:

select 學號,姓名 from 成績表,學生資訊表 where 成績表.學號=學生資訊表.學號 and 成績表.成績<60

10 select 學號,姓名,性別 from 學生資訊表 order by 學號 desc

這裡我把"學生表"寫成"學生資訊表",是為了看著更清楚

如果要改的話,自己看著改

6樓:匿名使用者

1,select * from 成績表

2,select 學好,姓名,年齡 from 學生表

查詢所有至少選修2門課程的學生的學號的語句怎麼寫?

7樓:匿名使用者

⑥ select distinct x.s#

from sc as x, sc as y

where x.s#=y.s# and x.c#!=y.c#;

8樓:匿名使用者

selece 學號 from 表 條件(選修課程大於或等於2的不就行了麼)

用sql查詢同時選修了1號課和2號課的學生學號

9樓:于曉楠買甘

查詢bai

同時選修了1號和2號課的學du生學號

涉及到兩zhi個表.學生表和dao課程表

語句:select

*from

student

inner

join

scon

student.sno=sc.sno

and**o

in('1','2')

為什麼不用內where

**o=』1『

and**o=』2『

這個關係到資料容庫的優化問題,哪個執行快,就寫哪個那個語句也可以這樣寫啊where

snoin

(select

snofrom

scwhere

sno=』1『

)and

snoin(select

snofrom

scwhere

sno=』2『)

10樓:吳

你好抄像寫錯了吧,襲

,,我感覺應該是bai

select sno

from sc

where **o='1' and son in (select sno from sc where **o='2');

或者where **o='1' intersert select sno from sc where **o='2');

intersect對兩個du查詢zhi做交集。相當於daoand

11樓:envy誒

因為這樣的意思是 在一行內課號既得等於1又得等於2 並沒有這樣的

12樓:匿名使用者

sno 指的是什麼?

bai**o指什麼? 上面的sql語句du是不可能zhi實現同樣的功能的。

sno如果是指dao學生學號;版

**o是指課程號的權

話。where **o=』1『 and **o=』2『是指課程號是1和2 的學生資訊。

where sno=』1『 and sno in(select sno

from sc

where sno=』2『)

是指學生學號是1和2 的學生,事實上,作為主鍵的sno沒有可能同時是1和2的。

請採納答案,支援我一下。

用sql查詢同時選修了1號課和2號課的學生學號怎麼查?

13樓:吳

你好像寫來錯了吧自,,,

我感覺應該是

select sno

from sc

where **o='1' and son in (select sno from sc where **o='2');

或者where **o='1' intersert select sno from sc where **o='2');

intersect對兩個查詢做交集。相當於and

sql求解 1、查詢選修了「軟體工程」課程學生的學號。 2、查詢所有學生的「c001」號課程成績,並按 10

14樓:匿名使用者

我汗,你連個表結構都沒有,讓人怎麼回答。

15樓:匿名使用者

其實我很好奇 前兩個問題是啥 lz沒貼出來

16樓:匿名使用者

憂固畢應券娛恆了夜爪

17樓:匿名使用者

創屑腥迫爹床盲都唯勸

SQL語言 如何編 查詢學生都選修了哪些課程,要求列出課程號

select 課程號 from c表,成績表 where c表.課程號 成績表.課程號 select distinct 課程號 from c表,成績表 where c表.課程號 成績表.課程號 sql查詢全部學生都選修的課程的課程號和課程名問題 用sql語句列出全部學員都選修的課程的課程名和課程號 ...

sql 查詢所有學生的學號 姓名 入學成績 選課門數和平均分

你select from 表的時候,from兩個表。後邊再where 表1.id 表2.id 暈了,我說的id也就是主外來鍵關係的列。也就是你說的學號 現在的學生啊 照著書一點點做比打這些字容易多了 sql語句的一道題 三個基本表 學生表 student 課程表 course 學生選課表 sc se...

sql資料庫問題查詢所有學生和教師的姓名允許重

select 姓名,性別 from teacherswhere 教師號 in select 教師號 from students where sno 03160111 例如 select 姓名,性別 from teachers,studentswhere students.學號 03160111 an...