create table test_tbl(col set('a,b,c,d'),index key(col));insert into test_tbl values('a,b,c,d');//使用位运算将col值更新为'a,c,d'?//查询条件中怎样使用位运算,查找所以包含'a'值的记录,能不能使用索引?

解决方案 »

  1.   

    你的这个例子中,COL只有一个值就是'a,b,c,d'这个字符串。楼主想问的问题到底是什么?要知道 'a,b,c,d'与 'a','b','c','d' 是不同的。建议举例说明。 并且自己先测试一下提供的例子。
      

  2.   

    alter table test_tbl modify col set('a','c','d');
      

  3.   


    已经改成这样。insert into test_tbl values('a'),('b'),('c'),('d');查找值为a的记录
    select * from test_tbl where col='a';//有索引
    select * from test_tbl where find_in_set('a',col);//无索引
    select * from test_tbl where col=col&1;//无索引想问一问,怎样查询含有'a'值的记录(不是等于'a'),才能使用索引?
    以及有没有办法直接得到set列的所有可能组合结果?
      

  4.   

    比如set('a','b','c','d')的所有可能结果是:
    a
    a,b
    a,b,c
    a,b,c,d
    b
    b,c
    b,c,d
    c
    c,d
    d