国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql如何查詢指定條件

2024-07-24 12:33:34
字體:
來源:轉載
供稿:網友
  本教程操作環境:windows10系統、mysql8.0.22版本、Dell G3電腦。
 
  mysql如何查詢指定條件
 
  從 MySQL 表中使用 SQL SELECT 語句來讀取數據。
 
  如需有條件地從表中選取數據,可將 WHERE 子句添加到 SELECT 語句中。
 
  一、定義
 
  使用where子句對表中的數據篩選,并將篩選結果輸出。
 
  二、語法
 
  select  字段列表 from 表名 where語句 ;
 
  三、分類
 
  1、按關系運算符篩選
 
  等于 =
 
  大于 >
 
  大于等于>=
 
  小于<
 
  小于等于<=
 
  不等于!=
 
  例子如下
 
  select name from student where name='張三'    ## 查詢name等于張三的數據
  select name from student where name!='張三'  ## 查詢name不等于張三的數據
  select name from student where age>20        ## 查詢age大于20的數據
  2、邏輯運算符
 
  and
 
  or
 
  not
 
  例子如下
 
  select * from student where age>10 and name='張三'  ##查詢age大于10且name等于"張三"的數據。
  select * from student where not name='張三'        ##查詢name不等于"張三"的數據。
  3、范圍查詢
 
  in
 
  between 大數值 and 小數值
 
  例子如下
 
  select * from student where age in (10,11)  ##查詢age等于10或者11的數據。
  select * from student where age=10 or age=11  ## 與上面語句等效。
  select * from student where age between 10 and 24 ##查詢age在10到24之間的數據,包含邊界值。
  4、空判斷
 
  select * from student where address is null       ##查詢address為null的數據
  select * from student where address is not null   ##查詢address不為null的數據
  5、模糊查詢
 
  like
 
  %表示任意多個字符(包括0)
 
  _表示任意一個字符
 
  escape:取消%或_字符的通配符特性
 
  例子如下
 
  select * from student where name like '王%'   ##查詢name中姓張的數據。
  select * from student where name like '張_    ##查詢name中兩個字姓張的數據。
  select * from student where name like '%A%%' escape 'A'  ##查詢name中含有"%"的數據
  以上是“mysql如何查詢指定條件”這篇文章的所有內容,感謝各位的閱讀!

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乐山市| 寿阳县| 项城市| 资阳市| 榆林市| 喜德县| 永春县| 双鸭山市| 莲花县| 乐陵市| 通渭县| 清水河县| 玉田县| 九龙城区| 财经| 台湾省| 新蔡县| 乐亭县| 武平县| 石楼县| 泸水县| 潮安县| 许昌县| 阜城县| 淅川县| 宁陕县| 双柏县| 康乐县| 马龙县| 山阳县| 道孚县| 田林县| 广饶县| 安徽省| 凌海市| 措美县| 西吉县| 曲周县| 基隆市| 石渠县| 眉山市|