比如说我的一个表有A,B,C,D字段
现在希望设置的查询条件为
如果A=1,则B必须=1;如果C=1,则D必须=1。符合这样的才筛选出来
请问这样的查询语句应该怎样写
where (a=1 and b=1) or (c=1 and d=1)
select * from tbl_user a where a.A=a.B AND a.A = ?
还有既然你已经知道A要等于的值了,你为什么条件里让B也等于这个值不就行了。。。在想什么?
where (a=1 and b=1) or (c=1 and d=1)
select * from table where 1=1 if(a=1, "and (a=1 && b=1)" , "and a=1") if(c=1, "and (c=1 && d=1)" , "and c=1") ;