單字元過濾 '_'
select * from t_employee where fname like '_erry'
多字元過濾 '%'
select * from t_employee where fname like 't%'
集合匹配過濾 [jt] :第乙個字母為j 或t的資訊
[^jt] 反集合: 第乙個字母不為j 或t 的資訊
select * from t_employee where fname like'[jt]%'
select * from t_employee where fname like '[^jt]%'
sql中查詢空值, 不能直接使用普通的等於來判斷, 要使用關鍵字'is null / is not null ',因為資料庫中一些特殊的設定會查詢不到
select * from t_employee where fage is null
select * from t_employee where fage is not null and fsalary>2000
反運算子 ' != 不等於 !< 不小於 ' 等 三種表達方式 '!'符只能在sqlserver db2 資料庫中 使用
select * from t_employee where fage!=23 and fsalary!<5000
select * from t_employee where fage<>23 and fsalary>=5000
select * from t_employee where not(fage=23) and not(fsalary<5000)not 反運算
萬用字元過濾 LIKE
前面介紹的所有操作符都是針對已知值進行過濾的,但是這種過濾方式不是在什麼時候都好用。利用萬用字元可以建立比較特殊資料的搜尋模式 萬用字元 用來匹配值的一部分的特殊字元,為了使用萬用字元,必須使用like操作符 搜尋模式 由字面值 萬用字元或兩者組合構成的搜尋條件 select prod id,pro...
SQL WHERE高階資料過濾
1.講解where子句建立功能更強 更高階的搜尋條件,將學習not和in操作符 上面我們將where子句在過濾資料時使用的都是單元的條件,為了更強的過濾控制,sql允許給出多個where子句,這些自己有兩種使用方式,即and子句或or子句使用方式.操作符 operator 用來聯結或改變where子...
SQL學習之高階資料過濾
一 高階資料過濾之in操作符 in 操作符用來指定條件範圍,範圍中的每個條件都可以進行匹配。in取一組由逗號分隔 括在圓括號中的合法值。如下 select itemid,itemname,checkvaluenum,checkvaluestring,resultlevel from t check ...