0603mysql練習 資料增刪改查

2022-09-18 19:51:10 字數 1488 閱讀 6041

1. 查詢出部門編號為

30的所有員工

select * from yg where deptno = 30;

2. 所有銷售員的姓名、編號和部門編號。

select ename,empno,deptno from yg where job = "銷售員

";3. 找出獎金高於工資的員工。

select * from yg where comm > sal;

4. 找出獎金高於工資

60%的員工。

select * from yg where comm > 0.6*sal;

5. 找出部門編號為

10中所有經理,和部門編號為

20中所有銷售員的詳細資料。

select * from yg where (deptno = 10 and job = "經理

")or(deptno = 20 and job = "

銷售員");

6.找出部門編號為10

中所有經理,部門編號為

20中所有銷售員,還有即不是經理又不是銷售員但其工資大或等於

20000

的所有員工詳細資料。

select * from yg where (deptno = 10 and job = "經理

")or(deptno = 20 and job = "

銷售員")or(job not in("

經理","

銷售員") and sal >= 20000);

7.無獎金或獎金低於1000

的員工。

select * from yg where comm <= 1000 or comm is null;

8. 查詢名字由三個字組成的員工。

select * from yg where ename like "___";

9.查詢

2000

年入職的員工。

select * from yg where hiredate like "2000%";

select * from yg where hiredate >= "2000-01-01" and hiredate <= "2000-12-31";

10. 查詢所有員工詳細資訊,用編號公升序排序

select * from yg order by empno asc;

11. 查詢所有員工詳細資訊,用工資降序排序,如果工資相同使用入職日期公升序排序

select * from yg order by sal desc,hiredate asc;

12.查詢姓周的兩個名字的員工。

select * from yg where ename like "周

_";查詢所有姓張的員工。

select * from yg where ename like "張

%";

mysql基礎複習 資料增刪改練習

create table my employees id int 10 first name varchar 10 last name varchar 10 userid varchar 10 salary double 10 2 create table users id int userid v...

MySQL資料增刪改

1 插入資料insert 1.插入完整資料 順序插入 語法一 insert into 表名 欄位1,欄位2,欄位3 欄位n values 值1,值2,值3 值n 語法二 insert into 表名 values 值1,值2,值3 值n 2.指定字段插入資料 語法 insert into 表名 欄位...

mysql的增刪改擦 Mysql 資料的增刪改

插入資料 insert 更新資料 update 刪除資料 delete 一 在mysql管理軟體中,可以通過sql語句中的dml語言來實現資料的操作,包括 1.使用insert實現資料的插入 2.update實現資料的更新 3.使用delete實現資料的刪除 4.使用select查詢資料以及。二 插...