我有一张表,有五个字段。如字段一 字段二 字段三 字段四  字段五
1   A    B    C    D    
2   C    D    E    F一般情况查询情况如下:
select 字段一 form 表 where 字段二='A' and 字段三='B' and 字段四='C' and 字段四='D'如果这四个参数顺序是随机的。如果一般查询就会造成以下结果。
select 字段一 form 表 where 字段二='D' and 字段三='B' and 字段四='A' and 字段四='C'这时候SQL语句怎样写,可以得到正确的结果?

解决方案 »

  1.   

    最后一个打错了,应该是
    select 字段一 form 表 where 字段二='A' and 字段三='B' and 字段四='C' and 字段五='D'第二个也是。
      

  2.   

    select 字段一 form 表 where 字段二='D' and 字段三='B' and 字段四='A' and 字段五 REGEXP '[a-z]'
      

  3.   

    如果这四个参数顺序是随机的。如果一般查询就会造成以下结果。
    select 字段一 form 表 where 字段二='D' and 字段三='B' and 字段四='A' and 字段四='C'把所有的组合加起来?select 字段一 form 表 where 字段二='A' and 字段三='B' and 字段四='C' and 字段五='D'
    union all
    select 字段一 form 表 where 字段二='A' and 字段三='C' and 字段四='B' and 字段五='D'
    .....
    select 字段一 form 表 where 字段二='D' and 字段三='B' and 字段四='C' and 字段五='A'
      

  4.   

    yueliangdao0608ABCD只是举例,内容可能是各种字符。SQL方法有人已经答复了,不知道MYSQL方法有什么内置函数可以解决,我对MYSQL不太熟。
      

  5.   

    什么意思啊?
    把mssql的回答贴出来,看一下