查看表列名
SHOW FIELDS from 表名
查看N条数据
limit N
例如:select * from user limit 50,查询用户表前50条数据
查看某列值字符长度大于2的结果
SELECT * FROM zhuce WHERELENGTH(user_yuanyin)>= 2
length是一个函数,判断字符的长度,>=2 应该写在外面
查看某字段的字符长度
SELECT LENGTH(字段名)
根据出生日期计算年龄
(YEAR(CURDATE())-YEAR(列名))
查询重复N条的数据
SELECT COUNT(personcard_no) AS c, personcard_no FROM eye_refraction_info WHERE del_flag = 0 GROUP BY personcard_no HAVING c = N
查看某个区间结果
SELECT DISTINCT * FROM eye_diab_visualacuity WHERE (ucvaleft BETWEEN 06 and 30) OR (ucvaright BETWEEN 06 and 30)
格式化时间
DATE_FORMAT(需要格式化的时间字段,'%y-%m_%d')
去掉重复统计数量
SELECT *,COUNT(DISTINCT personcard_no) FROM eye_refraction_info GROUP BY personcard_no