MySQL划重点-查询-条件
生活随笔
收集整理的這篇文章主要介紹了
MySQL划重点-查询-条件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
- select * from 表名;
?
- 在 select 后面列前使用distinct 可以消除重復的行
- select distinct gender from students;
一、條件
- 使用where子句對表中的數據篩選,結果為true的行會出現在結果集中
- 語法如下
- select * from 表名 where 條件;
select * from 表名 where id>2;邏輯運算符
- and
- or
- not
- select * from students where id>3 and gender=o;
模糊查詢
- like
- %任意多個字符
- _任意一個字符
- select * from students where name like '黃%';
范圍查詢
- in表示在一個非連續(xù)的范圍內
- select * from students where id in(1,3,5);
?
- between...and表示在一個連續(xù)的范圍內
- select * from students where id between 3 and 8 and gender=1;
空判斷
- 注意:null與' '是不同的
- 判空is null
- select * from students where hometown is null;
- 判非空is not null
?
????? 優(yōu)先級
- 小括號,not , 比較運算符,邏輯運算符
- and比or先運算,如果同時出現并希望先算or,需要結合()使用
?
轉載于:https://www.cnblogs.com/hizf/p/7554957.html
總結
以上是生活随笔為你收集整理的MySQL划重点-查询-条件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: EasyDSS高性能流媒体服务器前端重构
- 下一篇: 梦到自己娶媳妇好不好