mysql作業部落格網 MySQL 作業2

2021-10-21 01:48:15 字數 1518 閱讀 5679

1.建立表

id name class yuwen shuxue yingyu kexue wuli

1 xing 0411 80 75 60 91 85

2 xiao 0411 75 45 56 80 90

3 yue 0411 87 66 70 86 73

4 ming 0411 55 83 62 70 74

5 hong 0411 90 55 89 56 74

查詢yuwen及格人的姓名和yuwen成績

mariadb [(none)]> select name,yuwen from chengji where yuwen>=60;

查詢每一科都及格的人的姓名

mariadb [(none)]> select name from chengji where yuwen>=60 and shuxue>=60 and yingyu>=60 and kexue>=60 and wuli>=60;

查詢有任何一科不及格的學生的全部資訊

mariadb [(none)]> select * from chengji where yuwen<60 || shuxue<60 || yingyu<60 || kexue<60 || wuli<60;

2.員工個人資訊表

1. id name *** age sfzh tel sfzh 主鍵

mariadb [test]> create table t7 (

-> id int ,

-> name char(10),

-> *** enum('m','f'),

-> age int,

-> sfzh char(18) primary key,

-> tel char(11));

mariadb [test]> insert into t7 values (1,'jim','f','25','420112345678945657','54412356466' ),(2,'tom','f','30','420111456788913496','45687975643');

員工工資表

外來鍵2.sfzh 部門 崗位 底薪 工作績效 保險 總工資

mariadb [test]> create table t9 (sfzh char(18),bumen char(20),ganwei char(20),dixin int,gzjx int,baoxian int,zgz int,foreign key (sfzh) references t7(sfzh)on delete cascade on update cascade);

mariadb [test]> insert into t9 values

-> ('420112345678945657','it','dba',6000,6000,1000,11000),

-> ('420111456788913496','rs','jl',5000,2000,1000,6000);

1.員工的工資根據工資表資訊發放,現有乙個員工jim辭職,人事部刪除他的個人資訊記錄,要求會自動刪除工資表內的資訊

MySQL實驗作業 MySQL作業

題目一 使用連線查詢的方式,查詢出各員工所在部門的人數與工程數,工程數命名為count project。連線3個表,並使用count內建函式 create table employee id int 3 primary key,name varchar 20 age int 1 create tab...

mysql 檢視作業 mysql作業

dropdatabaseifexistsshopping createdatabaseshopping useshopping createtablesales idmediumintunsignednotnullprimarykeyauto increment,pronamevarchar 30 ...

mysql部落格園 mysql

一 聯合查詢 在兩種情況下可能用到 1 想要的結果在一條語句中會引起邏輯衝突,只能放在兩條語句中是要使用聯合查詢 2 一張表的資料量非常大時,會分隔成多張表儲存,要查詢時也要用到聯合查詢 2,聯合查詢中的order by必須搭配上limit關鍵字才能生效!因為系統預設的聯合查詢的結果往往比較多,所以...