select * from 字段 like '%AB_B%'

解决方案 »

  1.   

    select * from 表 where patindex('%AB_B%',字段)>0
      

  2.   

    select * from 字段 like '%AB[A-Z]B%'
      

  3.   

    select * from 字段 like '%[A-Z]B[A-Z]B%'
      

  4.   

    select * from tb where col like '%AB_B%'--orselect * from tb where patindex('%AB[A-Z]B%',Col)>0
      

  5.   

    if object_id('[tb]') is not null drop table [tb]
    create table [tb]([value] varchar(8))
    insert [tb]
    select 'ABxBAxA' union all
    select 'BxBABxAA' union all
    select 'BxBAxAB' union all
    select 'AxBxBAAx' union all
    select 'BxABBxA'select * from tb where value like '%AB_B%'
    /*
    value    
    -------- 
    ABxBAxA(所影响的行数为 1 行)
    */select * from tb where patindex('%AB_B%',value)>0/*
    value    
    -------- 
    ABxBAxA(所影响的行数为 1 行)
    */
      

  6.   


    select * from 表 where  字段 like '%[A-Z]B[A-Z]B%'
      

  7.   


    select * from tb where col like '%AB?B%'两边模糊用 %
    单个字符匹配不同数据库系统可能会有些差异,试试上面。有用问号代替的。
      

  8.   


    我的目标是要实现这样的匹配:
    ABxBAxA
    BxBABxAA
    BxBAxAB
    AxBxBAAx
    BxABBxA
      

  9.   

    --这个满足要求了吧
    ----------------------------------------------------------------
    -- Author :fredrickhu(小F 向高手学习)
    -- Date   :2009-06-27 16:35:26
    ----------------------------------------------------------------
    --> 测试数据:[tb]
    if object_id('[tb]') is not null drop table [tb]
    create table [tb]([value] varchar(8))
    insert [tb]
    select 'ABxBAxA' union all
    select 'BxBABxAA' union all
    select 'BxBAxAB' union all
    select 'AxBxBAAx' union all
    select 'BxABBxA'
    --------------开始查询--------------------------
    select * from tb where  value like '%[A-Z]B[A-Z]B%'
    ----------------结果----------------------------
    /*
    value    
    -------- 
    ABxBAxA
    BxBABxAA
    AxBxBAAx
    (所影响的行数为 3 行)
    */