欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL學習必備條件查詢數(shù)據(jù)

 更新時間:2022年03月25日 09:40:45   作者:江下下啊  
這篇文章主要介紹了MySQL學習必備條件查詢數(shù)據(jù),首先通過利用where語句可以對數(shù)據(jù)進行篩選展開主題相關(guān)內(nèi)容,具有一定的參考價值,需要的小伙伴可以參考一下,希望對你有所幫助

一、條件查詢

利用where語句可以對數(shù)據(jù)進行篩選

select * from 表名 where 條件;

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_運算符

二、比較運算符

? 運算符 ?

? 描述 ?

? 例子 ?

=

等于

where id = 1

\>

大于

where age > 10

<

小于

where age < 10

>=

大于等于

where age >= 10

<=

小于等于

where age <= 10

!=

不等于

where name != '老王'

select * from users where id = 1;

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_比較運算符_02

三、邏輯運算符

? 運算符 ?

? 描述 ?

? 例子 ?

and

并且

where id = 1 and age > 10

or

或者

where id = 1 or age > 10

not

取反

where not id = 1

select * from users where id = 1 and age = 24;

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_比較運算符_03

select * from users where not id = 1;

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_邏輯運算符_04

四、范圍查詢

? 運算符 ?

? 描述 ?

? 例子 ?

in

在指定的非連續(xù)范圍內(nèi)

where id in(1,3,5);

between ... and ...

在指定的連續(xù)范圍內(nèi)

where id between 1 and 5;

select * from users where id in (1,3,4);

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_運算符_05

select * from users where id between 1 and 5;

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_運算符_06

五、空判斷

? 運算符 ?

? 描述 ?

? 例子 ?

is null

判斷是否為空

where name is null

is not null

判斷是否不為空

where name is not null

 注:null與''是不一樣的

INSERT INTO users (name, birth_date, phone,age)
VALUES ('', '1990-01-01', '13813145213',30);

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_運算符_07

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_邏輯運算符_08

INSERT INTO users (name, birth_date, phone,age)
VALUES (null, '1990-01-01', '13813145213',30);

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_運算符_09

INSERT INTO users (name, birth_date, phone,age)
VALUES ('老張', null, '17813145213',30);

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_邏輯運算符_10

select * from users where birth_date is null;

#yyds干貨盤點# 06 MySQL條件查詢數(shù)據(jù)_邏輯運算符_11

六、模糊查詢

select * from users where name like '王%';

select * from users where name like '%王';

七、優(yōu)先級

  • 小括號,not,比較運算符,邏輯運算符
  • and比or先運算,如果同時出現(xiàn)并希望先算or,需要結(jié)合()使用

 到此這篇關(guān)于MySQL學習必備條件查詢數(shù)據(jù)的文章就介紹到這了,更多相關(guān)MySQL條件查詢數(shù)據(jù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論