库里的url字段有
/20090409/238_131144035_2.jpg

/20090407/2387520_165456098_2.jpg我用like '%/238_%'想找带/20090409/238_131144035_2.jpg这样格式的记录值,系统却连/20090407/2387520_165456098_2.jpg这种记录都一块都列出来了,这是为什么啊?我的是SQL2005

解决方案 »

  1.   

    where charindex('/238_',url)>0
      

  2.   

    --> 测试数据:dep
    if object_id('dep') is not null
    drop table dep---->建表
    create table dep([T1] varchar(33))
    insert dep
    select '/20090409/238_131144035_2.jpg' union all
    select '/20090407/2387520_165456098_2.jpg'--> 查询结果
    SELECT * FROM dep where T1 like '%/238\_%' escape '\'
    --> 删除表格
    --DROP TABLE dep
    ----结果
    T1
    /20090409/238_131144035_2.jpg