美文网首页
MYSQL模糊查询

MYSQL模糊查询

作者: Aluha_f289 | 来源:发表于2018-03-10 19:33 被阅读0次

    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

    相关文章

      网友评论

          本文标题:MYSQL模糊查询

          本文链接:https://www.haomeiwen.com/subject/kqjbfftx.html