數據庫表
表名:student
ID | name | age |
---|---|---|
1 | 王小明 | 23 |
2 | 王大明 | 24 |
3 | 李華 | 13 |
3 | 李明 | 13 |
關鍵語句
- like:查詢列表中包含同名內容的字段
語句
select * from 表名 where 字段 like "--"
語句形式
ID | name |
---|---|
%a | 以a結尾的數據 |
a% | 以a開頭的數據 |
%a% | 含有a的數據 |
_ a _ | 三位且中間字母是a的 |
_ a | 兩位且結尾字母是a的 |
a _ | 兩位且開頭字母是a的 |
舉例
查詢以“明'結尾的字段
select * from student where name like "%明"
ID | name | age |
---|---|---|
1 | 王小明 | 23 |
2 | 王大明 | 24 |
3 | 李明 | 13 |
查詢以“王'開頭的字段
select * from student where day name "王%"
ID | name | age |
---|---|---|
1 | 王小明 | 23 |
2 | 王大明 | 24 |