- 选择数据库 use database;
- 展示数据库/表 show databases;/show tables;
- 检索不同行(去重)distinct 例:select distinct id from table;
- 限制结果(限制行数)limit 例:select name from table limit 5;
- 检索单个列 例:select name from table;
- 检索多个列 例:select id,name,age from table;
- 排序数据order by(升序:asc/降序:desc)例:select id from table order by name;
- 空值检查 null 例:select name from table where price is null;
- 范围值检查between and 例:select name from table where price between 5 and 10;
- 百分号通配符%('%彭%'/'彭%'/'%彭')例:select id,name from table where name like '%王%';
- 下划线(_)通配符 例:select id,name from table where name like '_芙蓉';
- 基本字符匹配regexp 例:select name from table where name regexp '.000' order by name;
- 匹配字符之一 例:select name from table where name regexp '[123] ton' order by name;
- 匹配特殊字符\\ 例:select name from table where name regexp '\\.' order by name;
- 匹配多个实例 例:select name from table where name regexp '\\([0-9] sticks?\\)' order by name;
- 匹配任意数字[[:digit:]] 例:select name from table name regexp '[[:digit:]]{4}' order by name;
- 拼接concat 例:select concat(name, '(',country,')') from table order by name;
- 去掉右边的所有空格rtrim 例:select concat(rtrim(name),'(',rtrim(county),')') from table order by name;
- 匹配发音类似 soundex() 例:select name,age from table where soundex(name)=soundex('Y Lie');
- union编写多条select语句 例:select a_id,b_id,b_price from table where price<=5 union select a_id,b_id,b_price from table where a_id in (1001,1002);
- 包含或取消重复的行union all 例:select select a_id,b_id,b_price from table where price<=5 union all selecta_id,b_id,b_price from table where a_id in (1001,1002);
- 按指定要求进行顺序排序 field() 例: