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
网友评论