DQL語言的查詢

2021-09-29 17:11:35 字數 1283 閱讀 5272

分類:

一、按條件表示式篩選

條件運算子:> 、< 、= 、!=(<>) 、>= 、<=

二、 按邏輯表示式篩選

邏輯運算子: &&(and)、 ||(or)、 !(not)

三、 模糊查詢

like、between and、in、is null或is not null

語法:

select  查詢列表   3

from 表名 1

where 條件 2

eg 1、查詢工資大於10000的員工資訊

select

*from employees where salary >

10000

;

eg 2、查詢工資在一萬到兩萬之間的員工資訊

select

*from employees where salary >=

10000

and salary <=

20000

;

eg 1、查詢員工名中包含字元a的員工資訊

select

*from employees

where last_name like

'%a%'

;

說明:

like一般要和萬用字元使用

萬用字元 %:零個或任意多個字元

_ :乙個字元

eg 1、查詢員工編號在100~120的員工資訊

select

*from employees

where employee_id between

100and

120;

eg 1、查詢員工工種編號是it_prog 、ad_vp 中的乙個員工名和工種編號

select last_name,job_id

from emloyees

where job_id in

('it_prog'

,'ad_vp'

);

eg 1、查詢沒有獎金的員工名和獎金率

select last_name,comimission_pct

from employees

where comimission_pct is

null

;

注意要判斷是否為空必須用is,而不是=

DQL語言 排序查詢

查詢員工資訊,要求工資從高到低排序,使用order by 降序select from employees order by salary desc 公升序 select from employees order by salary asc 注意 如果不寫,預設是公升序 查詢部門編號 90的員工資訊,...

DQL語言 基礎查詢

一,語法 select 查詢列表 from 表名 二,特點 1,查詢列表可以是字段,常量,表示式,函式 2,查詢結果是虛擬表 示例 1,查詢單個字段 select 欄位名 from 表名 select department id from departments 2,查詢多個字段 select 欄位...

DQL語言 基礎查詢

select 查詢列表 from 表名 1 查詢列表可以是字段 常量 表示式 函式,也可以是多個 2 查詢結果是乙個虛擬表 1 查詢單個字段 select 欄位名 from 表名 2 查詢多個字段 select 欄位名1,欄位名2,from 表名 3 查詢所有字段 select from 表名 4 ...