MYSQL模糊查询

2018-03-10  本文已影响0人  Aluha_f289

1.公式
select * from 表名 where 字段 Like 条件
2.%可以匹配0个或者多个字符
eg:mysql> select *from persons where LastName Like '老%';
+----+----------+-----------+---------+--------+
| id | LastName | FirstName | Address | City |
+----+----------+-----------+---------+--------+
| 4 | 老1 | one | 204 | Fujian |
| 5 | 老2 | one | 204 | Fujian |
| 6 | 老3 | one | 204 | Fujian |
+----+----------+-----------+---------+--------+
3._只能匹配一个字符
egg:mysql> select *from persons where LastName Like '_1';
+----+----------+-----------+---------+--------+
| id | LastName | FirstName | Address | City |
+----+----------+-----------+---------+--------+
| 4 | 老1 | one | 204 | Fujian |
+----+----------+-----------+---------+--------+
1 row in set

上一篇下一篇

猜你喜欢

热点阅读