MySQL study notes. Query dataOne

Query all fields

语法格式:
SELECT * FROM 表名;

Insert picture description here

Query specified field

语法格式:
SELECT 字段名 FROM 表名;

Insert picture description here

Query multiple fields

语法格式:
SELECT 字段名1,字段名2,... FROM 表名;

Insert picture description here

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;

Insert picture description here
Check the fruit price is less than 5 yuan
Insert picture description here

Query with IN keyword

Insert picture description here
Insert picture description here

Range query with BETWEEN AND

Insert picture description here
Insert picture description here

Character matching query with LIKE

1.% matches characters of any length.
Find all fruits starting with a
Insert picture description here
Insert picture description here
. 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.
Insert picture description here

Multi-condition query with AND

Query fruits with s_id=101 and f_price<10

Insert picture description here

Multi-condition query with OR

Insert picture description here

The query result is not repeated

语法格式
SELECT DISTINCT 字段名 FROM 表名;

Insert picture description here

Sort query results

Insert picture description here
descending sort
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44862120/article/details/108918567