Single table query
Query all fields
语法格式:
SELECT * FROM 表名;
Query specified field
语法格式:
SELECT 字段名 FROM 表名;
Query multiple fields
语法格式:
SELECT 字段名1,字段名2,... FROM 表名;
Query specified records
语法格式:
SELECT 字段名1,字段名2...
FROM 表名
WHERE 查询条件
Check for fruits with a price of 8.2
SELECT f_name,f_price
FROM fruits
WHERE f_price=8.2;
Check the fruit price is less than 5 yuan
Query with IN keyword
Range query with BETWEEN AND
Character matching query with LIKE
1.% matches characters of any length.
Find all fruits starting with a
. 2. Underscore wildcard _, which can only match one character at a time.
Query records that start with the letter m and are followed by three letters.
Multi-condition query with AND
Query fruits with s_id=101 and f_price<10
Multi-condition query with OR
The query result is not repeated
语法格式
SELECT DISTINCT 字段名 FROM 表名;
Sort query results
descending sort