国产探花免费观看_亚洲丰满少妇自慰呻吟_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如何查詢指定條件”這篇文章的所有內容,感謝各位的閱讀!

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邯郸县| 察隅县| 十堰市| 桃园县| 丹东市| 科技| 荣昌县| 睢宁县| 德钦县| 宝清县| 新化县| 改则县| 榆中县| 前郭尔| 威宁| 义马市| 长岭县| 苗栗县| 本溪市| 石棉县| 明水县| 灵宝市| 徐闻县| 施甸县| 汉阴县| 金堂县| 无为县| 平原县| 延安市| 朝阳区| 南丰县| 开阳县| 江油市| 读书| 门头沟区| 青神县| 额济纳旗| 通河县| 紫阳县| 建宁县| 博客|