1.对表的操作
假设有表student:
id | name | course | score |
---|---|---|---|
1 | 张一 | 语文 | 50 |
2 | 张二 | 数学 | 50 |
3 | 张三 | 语文 | 60 |
4 | 张四 | 英语 | 80 |
5 | 张五 | 英语 | 65 |
6 | 张二二 | 英语 | 95 |
- 根据字段查询:
> select * from student where name='张三'
查询结果列为:张三
- 模糊查询:
- %:表示零个或多个字符,中文使用两个百分号
> select * from student where name like '%二%'
查询结果列为:张二,张二二
- _:表示任意单个字符,可用来限制查询长度
> select * from student where name like '_二'
查询结果列为:张二
> select * from student where name like '_二_'
查询结果列为:张二二
- [ ]:表示括号内所列字符中的一个(类似正则表达式)
> select * from student where name like '张[一二三]'
查询结果列为:张一,张二,张三
- [^]:表示不在括号所列之内的单个字符。