积极答复者
【ASP】多字段组合筛选数据问题

问题
-
有6个字段 分别为 field1,field2,field3,sfield1,sfield2,sfield3 其中如果 field1,field2,field3分别为1 sfield1,sfield2,sfield3 不等1时才显示数据
我是这样写的 select * from table where (field1=1 or field2=1 or field3=1) and (sfield1<>1 or sfield2<>1 or sfield3<>1) 但是没有达到预想效果 请专家指教 谢了
煜诚海参专卖 淘宝店铺:http://jinweb.taobao.com
答案
-
应该都用and。参考下面的语句试试:
select * from table where (field1=1 and field2=1 and field3=1) and (sfield1<>1 and sfield2<>1 and sfield3<>1)
family as water
煜诚海参专卖 淘宝店铺:http://jinweb.taobao.com
我用了一个笨的方法解决了,先是在数据库新建了一个字段。又定义了一个变量x。在插入数据库之前我首先判断前面的变量也就是 sfield1<>1 and sfield2<>1 and sfield3<>1 如果满足条件的话 赋值新声明的变量x 然后根据变量x判断就可以了不知道谁还有什么其他的方法 请指教
煜诚海参专卖 淘宝店铺:http://jinweb.taobao.com- 已标记为答案 Mog Liang 2011年2月7日 6:47
全部回复
-
应该都用and。参考下面的语句试试:
select * from table where (field1=1 and field2=1 and field3=1) and (sfield1<>1 and sfield2<>1 and sfield3<>1)
family as water
煜诚海参专卖 淘宝店铺:http://jinweb.taobao.com
我用了一个笨的方法解决了,先是在数据库新建了一个字段。又定义了一个变量x。在插入数据库之前我首先判断前面的变量也就是 sfield1<>1 and sfield2<>1 and sfield3<>1 如果满足条件的话 赋值新声明的变量x 然后根据变量x判断就可以了不知道谁还有什么其他的方法 请指教
煜诚海参专卖 淘宝店铺:http://jinweb.taobao.com- 已标记为答案 Mog Liang 2011年2月7日 6:47