BETWEEN...AND 運(yùn)算符
決定某一人數(shù)值是否介于特定的范圍之內(nèi),此運(yùn)算符只可以用在SQL的語(yǔ)句中。
expr[Not]BETWEEN value1 AND value2
expr
指定要加以計(jì)算的字段與表達(dá)式的組合。
value1,value2
所指明的數(shù)值范圍。
例如:
若是要從職員表格查詢出所有年齡介于25-30歲的員工,可以利用下面的程序來做。
SELECT 姓名,年齡 BETWEEN 25 AND 30
FROM 職員表格;
LIKE 操作數(shù)
用來將一字符串與另一特定字符串樣式(pattern)比較,并將符合該字符串樣式的記錄過濾出來。
expression LIKE "pattern"
expression
使用在WHERE條件子句,SQL表達(dá)式。
pattern
用以比較的字符串樣式。
例如:
若是你要查詢出所有以“李”為首的姓氏,可以利用下面的式子。
Like "李*"
LIKE操作數(shù)的多種范例:
1、多個(gè)字符:
(1)"a*a"
可篩選:"aa","aBa","aBBBa",不能篩選:"aBC"
(2)"*ab*"
可篩選:"abc","AABB","Xab",不能篩選:"aZb","bac"
2、特殊字符:
"a“*”a"
可篩選:"a*a",不能篩選:"aaa"
3、單一字符:
"a?a"
可篩選:"aaa","a3a","aBa",不能篩選:"aBBBa"
4、單一數(shù)字:
"a#a"
可篩選:"a0a","a1a","a2a",不能篩選:"aaa","a10a"
5、字符范圍:
"“a-z”"
可篩選:"f","p","j",不能篩選:"2","&"
6、指定字符以外部范圍:
"“!a-z”"
7、指定非數(shù)字:
"“!0-9”"
可篩選:"A","a","&","~",不能篩選:"0","1","9"
8、組合式結(jié)構(gòu):
"a“!b-m”#"
可篩選:"An9","az0","a99",不能篩選:"abc","aj0"