1. 删除视图表
drop view v_1;
2. 去重:过滤完全相同的数据行
select distinct * from test1;
3. 筛选:根据指定条件
select distinct * from test1 where id=5;
4. 筛选:与、或
select distinct * from test1 where id=5 or (name='ddd' and id>3);
5. 获取指定内容
select distinct * from test1 where name in ('AAA','ddd');
6. 指定范围内的数据
select * from test1 where name between 'AAA' and 'ddd';
7. MySQL中的两个通配符:%、_
不细说了,重要,细说复杂
符号 | 说明 |
---|---|
% | 百分号表示零个、一个或多个字符 |
_ | 下划线表示单个字符 |
SELECT * FROM fw WHERE saleroom like '%40%';
8. 排序
select * from test1 order by id desc;