MySQL是一個客戶端-服務(wù)器關(guān)系型數(shù)據(jù)庫管理系統(tǒng),支持多用戶、多線程的“關(guān)系型數(shù)據(jù)庫管理系統(tǒng)”,為了方便在MySQL中進(jìn)行數(shù)據(jù)的篩選、篩選、分析等操作,有時需要用到各種符號進(jìn)行條件的匹配。常見的符號包括以下幾種:
= 等于 != 不等于<>不等于< 小于 >大于<= 小于等于 >= 大于等于 LIKE 模糊匹配 IN 匹配集合中的值 BETWEEN 在范圍內(nèi) NOT 不匹配 AND 且 OR 或
等于(=)符號是最常用的符號之一,它表示左邊的值與右邊的值相等。例如:
SELECT * FROM students WHERE name = '張三';
不等于符號(!=和<>)在MySQL中表示左邊的值和右邊的值不相等。例如:
SELECT * FROM students WHERE gender != '男';
小于(<)和大于(>)符號用于比較兩個數(shù)值的大小,例如:
SELECT * FROM students WHERE score< 60; SELECT * FROM students WHERE age >18;
小于等于(<=)和大于等于(>=)符號則表示左邊的值小于等于或大于等于右邊的值,例如:
SELECT * FROM students WHERE age<=18; SELECT * FROM students WHERE score >= 90;
LIKE符號用于模糊匹配,例如:
SELECT * FROM students WHERE name LIKE '張%'; SELECT * FROM students WHERE address LIKE '%北京市%';
IN符號用于匹配集合中的值,例如:
SELECT * FROM students WHERE age IN (18,20,22); SELECT * FROM students WHERE name IN ('張三','李四','王五');
BETWEEN符號則在范圍內(nèi)篩選值,例如:
SELECT * FROM students WHERE score BETWEEN 60 AND 80; SELECT * FROM students WHERE age BETWEEN 20 AND 30;
NOT符號用于表示不匹配,例如:
SELECT * FROM students WHERE name NOT LIKE '張%'; SELECT * FROM students WHERE age NOT BETWEEN 20 AND 30;
AND符號表示”且“,OR符號表示”或“,它們用于連接多個條件,例如:
SELECT * FROM students WHERE age >18 AND score >=60; SELECT * FROM students WHERE gender = '男' OR gender = '女';
以上就是MySQL中常用的一些符號,它們用于方便快速查詢數(shù)據(jù)庫中正確的數(shù)據(jù)。