MySQL必知必會3-過濾數據

3.過濾數據

1.使用where子句

select * from table where field1 = 1;

2.where子句操作符

  操作符         說明
     =           等於
    <>           不等於
    !=           不等於
    <             小於
    >             大於
    >=            大於等於
    BETWEEN       在兩數之間

1.檢查單個值

select * from table where field1 = 'good';

2.不匹配查詢

//查詢出字段field1不等於10的數據
select * from table where field1 <> 10;

3.範圍查詢

//查詢字段field1在範圍5到8之間的數據(相當於>=5且<=10)
select * from tabel where field1 BETWEEN 5 AND 10;

4.空值查詢

//查詢字段field1爲空的數據
select * from table where field1 IS NULL;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章