如,设置一个字段flag为set('c','p','h')。
那么SQL语句,如何查询出:
select * from table where flag=?请问如何写,假设置我要查询,set=c的呢?或者说set=c 并且set=p呢?谢谢。

解决方案 »

  1.   

    试试
    select * from table where flag=1
      

  2.   

    select * from table where flag='c'
      

  3.   


    这个SQL语句,只是查询flag字段里面只有c,如果有一条记录里的flag为c,p,则查询不出来。
      

  4.   

    不可能,第1个结果可以:
    where flag=1
    以此类推,
    看看结果
    select *,0+flag from table select * from table where flag=1 and flag=3
      

  5.   


    你的这个结果和ACMAIN_CHM老大的,也是一样,只是单独查询出flag=c,不能查询出flag中包括c,p的记录。
      

  6.   

    不能查询出flag中包括c,p的记录。
    select * from table where INSTR(flag,'c')>0 and INSTR(flag,'p')>0
      

  7.   

    我现在发现set类型,有什么优势之处呢?是用多个字段来表示比较好呢?还是用set。
      

  8.   

    select *,0+flag from table 看看结果就知道了
    根据你的具体用途,一般用set
      

  9.   

    select * from table where find_in_set('c',flag)