比如一个表中有一个字段值为 1,2,3,11,12,126,112, 等内容现在查查询所有记录中 这个字段值有 11  的所有数据,怎么写sql条件呢?

解决方案 »

  1.   

    select * from tablename where column='%11%'
      

  2.   

    问的有嫩简单吗?
    select * from tablename where column like '%11%'
      

  3.   

    select * from 表单 where 列名 like '%11%'
    加入70915510技术交流群
      

  4.   

    select * from 表单 where 列名 like 
    如果字段中有111,112 这样的值,'%11%' 一样会被搜索出来。
      

  5.   

    如果是字段类型为字符型的按照楼上说的
    select * from tablename where 字段 like '%11%'如果字段类型为数值型的则可这样:
    select * from tablename where convert(varchar(20),字段) like '%11%'
      

  6.   

    select * from tablename where 字段 like '%11,%' or 字段 like '%,11,%' or 字段 like '%,11%'用一个like结果是不正确的,必须要加,才能有正确的结果
      

  7.   

    select * from tablename where 字段 like '11,%' or 字段 like '%,11,%' or 字段 like '%,11' or 字段='11' 上面打错了
      

  8.   

    就是因为111,112 这样的值会被 like '%11%'查出来,所以SQL语句得考虑边界
    select * from tablename where 字段 like '11,%' or 字段 like '%,11,%' or 字段 like '%,11' or 字段='11' 
      

  9.   

    select * from tablename where column='%11%'
      

  10.   

    select * from tablename where column='%11%'
      

  11.   


    select * from yourtable where yourcolumn like '%,11,%'带上逗号