美文网首页
模糊匹配like

模糊匹配like

作者: summer琴 | 来源:发表于2020-04-05 16:33 被阅读0次

    like用在where条件语句中

    基本用法:

    SELECT column_name(s)
    FROM table_name
    WHERE column_name LIKE pattern;
    

    通配符%表示0个或任易个字符,[0-9]表示任意数字,[a-z]表示任意小写字母,[A-Z]表示任意大写字母

    eg.

    • 查找idoxu表,名称(c_name)包含 “i” 的数据
    select * from idoxu where c_name like '%i%';
    
    • 查找idoxu表,名称(c_name)以 “i” 开头的数据
    select * from idoxu where c_name like 'i%';
    
    • 查找idoxu表,名称(c_name)以“i”结尾 的数据
    select * from idoxu where c_name like '%i';
    
    • 查找idoxu表,名称(c_name)包含数字的数据
    select * from idoxu where c_name like '%[0-9]%';
    
    • 查找idoxu表,名称(c_name)包含小写字母的数据
    select * from idoxu where c_name like '%[a-z]%';
    
    • 查找idoxu表,名称(c_name)包含大写字母的数据
    select * from idoxu where c_name like '%[A-Z]%';
    

    相关文章

      网友评论

          本文标题:模糊匹配like

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