请问类似 WHERE FullName LIKE '[王李张]小军' 这样的条件从句,可以从姓名列中查出叫“王小军”、“李小军”或“张小军”的记录吗?

解决方案 »

  1.   

    if '王小军' LIKE '[王李张]小军'
    and '李小军' LIKE '[王李张]小军'
    and '张小军' LIKE '[王李张]小军' 
          select 'ok'
    else
          select 'not ok'
      

  2.   

    可以:
    create table #t
    (fullname varchar(20))
    insert into #t select '王小军'
    insert into #t select '李小军'
    insert into #t select '张小军'
    select * from #t where fullname like '[王李张]小军' 
    /*
    王小军
    李小军
    张小军
    */
      

  3.   

    这样?
    declare @tb table (fullname nvarchar(20))
    insert into @tb
    select '张小军' union all
    select '李小军' union all
    select '王小军' union all
    select 'AAAA' union all
    select '张小'select * from @tb where fullname like '_小军'
    /*
    fullname
    --------------------
    张小军
    李小军
    王小军
    */
      

  4.   

    declare @tb table (fullname nvarchar(20))
    insert into @tb
    select '张小军' union all
    select '李小军' union all
    select '王小军' union all
    select 'AAAA' union all
    select '张小'select * from @tb where fullname like '[王李张]小军' /*
    fullname
    --------------------
    张小军
    李小军
    王小军
    */
      

  5.   

    呵呵..当然完全可以!
    SQL 2005
      

  6.   

    可以,sql server不会有半个字符的问题
      

  7.   

    R
    A
    N
    Z
    J