有一个表id a b
----------------------------------------
1 0 0
2 1 0
3 1 1
4 1 2
5 2 1
----------------------------------------b有数值时候a必定有数值。
希望当符合条件时候显示不同的行
a = 0 and b = 0
返回全部内容
---------------------------------a = 1 and b=0
返回
id a b
----------------------------------------
2 1 0
3 1 1
4 1 2
---------------------------------
a = 1 and b=1
返回
id a b
----------------------------------------
3 1 1
我是这样写的sql语句
ax bx 是传入的参数(a=0 or b=0 or b=bx) and (a=ax and b=0)
有点晕了,大家帮忙看看吧,谢谢了。
----------------------------------------
1 0 0
2 1 0
3 1 1
4 1 2
5 2 1
----------------------------------------b有数值时候a必定有数值。
希望当符合条件时候显示不同的行
a = 0 and b = 0
返回全部内容
---------------------------------a = 1 and b=0
返回
id a b
----------------------------------------
2 1 0
3 1 1
4 1 2
---------------------------------
a = 1 and b=1
返回
id a b
----------------------------------------
3 1 1
我是这样写的sql语句
ax bx 是传入的参数(a=0 or b=0 or b=bx) and (a=ax and b=0)
有点晕了,大家帮忙看看吧,谢谢了。
a = 0 and b = 0
返回全部内容还是
ax = 0 and bx = 0
返回全部内容
[align=center]==== 思想重于技巧 ====
[/align]
或者
ax = 0 and bx = 0
时候都返回全部数据多谢帮忙啊~~~
----------------------------------------
1 0 0
2 1 0
3 1 1
4 1 2
5 2 1
---------------------------------------- 你的数据中第一条已经a=0 and b=0了,准备返回所有记录?
[align=center]==== 思想重于技巧 ====
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
http://www.access911.net/csdn/FileDescription.asp?mdb=2008-5-14&id=49请帮忙啊~~
from yourTable
where (a=1 or @ax=0) and (b=1 or @bx=0 or @ax=0);
[align=center]==== 思想重于技巧 ====
[/align]
where
(a=0 and b=0 ) or
(a=ax and b=0) or
(a=ax and b=bx)
[align=center]==== 思想重于技巧 ====
[/align]
from test
where b=0 or (a=ax and b=bx)
[align=center]==== 思想重于技巧 ====
[/align]
where
(a=0 or a=ax) and
(b=0 or b=bx)