當前位置:首頁 » 編程語言 » 選課時間用sql怎麼表示
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

選課時間用sql怎麼表示

發布時間: 2022-11-26 05:52:25

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

第一問:兩個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 cno=course.cno) 的課,只不過用not exists否定掉了*/

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

② 關於學生,課程,選課三張表的sql查詢

select 選課.學號,姓名,AVG(成績)'平均分',COUNT(選課.課程號)'選課門數' from 學生,課程,選課 where 學生.學號=選課.學號 and 課程.課程號=選課.課程號 group by 選課.學號,姓名 HAVING COUNT(選課.課程號)>4 ORDER BY AVG(成績) DESC
--------------------------------------
CREATE VIEW 查詢 AS
select top 100 選課.學號,姓名,AVG(成績)'平均分',COUNT(選課.課程號)'選課門數' from 學生,課程,選課 where 學生.學號=選課.學號 and 課程.課程號=選課.課程號 group by 選課.學號,姓名 HAVING COUNT(選課.課程號)>4 ORDER BY AVG(成績) DESC

其中DESC是降序排列,ASC是升序排列,默認是升序
ORDER BY AVG(成績)也可以寫成ORDER BY 平均分,因為已經指定了別名
「CREATE VIEW 查詢」中的「查詢」是新表名, 如果有「ORDER BY AVG(成績) DESC 」這句,則須有「top」,否則出錯「除非同時指定了 TOP,否則 ORDER BY 子句在視圖、內嵌函數、派生表和子查詢中無效。」

③ 急求!!!用SQL查詢學生的所有選課信息的語句該怎麼寫前面已經建好了Student、Course和SC的表了

selectstudent.sname,course.cname--查詢學生名,課程名
fromstudent,course,scwherestudent.sno=sc.snoandcourse.cno=sc.cno--三個表之間的關聯
orderbystudent.sname--按姓名排序

欄位名有跟你不一樣的,自行修改一下

④ 怎麼用sql語句查詢一個學生的選課情況,並列出課程信息

selectstu.name,course.*
fromstu,course,chicewherestu.sid=chice.sidandcourse.c_id=choice.c_id
andstu.name='張三'--這個地方輸入你想查的人名,如果這句不寫則查詢全部

⑤ 選課系統,可以根據專業不同動態的選擇課程,用sql語句實現。

這個是簡單的兩個下拉框之間的組合查詢,你要做的是在第一個下拉框綁定事件,然後再這個時間裡面,根據第一個下拉框選擇的值,來綁定第二個下拉框的值,
怎麼綁定下拉框和寫事件,不需要教你吧

⑥ 怎麼寫sql的語句

1.update 選課 set 成績=成績+5 where 課程號 in (select 課程號 from 課程 where 課程名="資料庫"x0dx0a2.update 選課 set 成績=0 where 課程號="2"x0dx0a3.update 選課 set 成績=85 where 學號 in (select 學號 from 學生 where 姓名="李勇"x0dx0a4.delete from 選課 where 課程號="2" and 成績 is nullx0dx0a5.delete from 課程 where 課程號 not in (select 課程號 from 選課)x0dx0a6.delete from 選課 where 課程號 in (select 課程號 from 課程名="資料庫") and 學號 in (select 學號 from 學生 where 系名="計算機")x0dx0a7.select 系名,sum(*) as 人數 from 學生 group by 系名,性別 into table 學生分類x0dx0a8.select 學號,count(*) as 課程數,avg(成績) as 平均成績 from 選課 where avg(成績)>=80 into table 成績表x0dx0a9.create view 無選修 as select 學號,姓名,系名 from 學生 where 學號 not in (select 學號 from 選課)x0dx0aselect * from 無選修x0dx0a10. create view 成績 as select 姓名,課程名,成績 from 學生,課程,選課 where 學生.學號=選課.學號 and 選課.課程號=課程.課程號 x0dx0aselect * from 成績x0dx0a11.create view 平均 as select 課程號,count(*) as 選課人數,avg(成績) as 平均分,max(成績) as 最高分 from 選課 group by 課程號x0dx0aselect 選課人數,平均分,最高分 from 平均 where 課程號="1"x0dx0a12.create view 平均1 as select 學號,成績 from 選課 where 課程號="2" and 成績>(select avg(成績) from 選課 where 課程號="2")

⑦ SQL中在成績表中增加「選課時間」欄位,日期型,默認值為當前系統日期。的命令怎麼寫 啊

Alter table 成績表
add 選課時間 datetime default getdate()

⑧ SQL選課表如何判斷選課時間重復

這個你描述的不是很清楚
如果是表裡的數據 可以分組查數量
例如
select name ,count(*) from table_name where shijian=** group by name having count(*)>1
但是如果表中沒有,是新增數據 ,則
let v_count = select count(*)from table_name where shijian=**
if v_count=0 then
insert ****
else
時間重復