我有一张表,有五个字段。如字段一 字段二 字段三 字段四 字段五
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 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语句怎样写,可以得到正确的结果?
select 字段一 form 表 where 字段二='A' and 字段三='B' and 字段四='C' and 字段五='D'第二个也是。
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'
把mssql的回答贴出来,看一下