View table column names
SHOW FIELDS from 表名
View N pieces of data
limit N
For example: select * from user limit 50, query the first 50 pieces of data in the user table
View the results of a column value whose character length is greater than 2
SELECT * FROM zhuce WHERELENGTH(user_yuanyin)>= 2
length is a function to judge the length of the character, >=2 should be written outside
Check the character length of a field
SELECT LENGTH(field name)
Calculate age based on date of birth
(YEAR(CURDATE())-YEAR(column name))
Query data that repeats N items
SELECT COUNT(personcard_no) AS c, personcard_no FROM eye_refraction_info WHERE del_flag = 0 GROUP BY personcard_no HAVING c = N
View a range of results
SELECT DISTINCT * FROM eye_diab_visualacuity WHERE (ucvaleft BETWEEN 06 and 30) OR (ucvaright BETWEEN 06 and 30)
format time
DATE_FORMAT (time field that needs to be formatted, '%y-%m_%d')
remove duplicate statistics
SELECT *,COUNT(DISTINCT personcard_no) FROM eye_refraction_info GROUP BY personcard_no