sql - MYSQL statement together OR and AND -


i have table in mysql named sale 3 columns below : sale:

id|customers|type 

i want select sales has type!=2 or sales has type=2 , customers!=0

i write statement :

sale.type != 2 or (sale.type = 2 , sale.customers != 0 ) 

but doesn`t give me correct rows .

also have use , other columns in query operators between of them , , here use or .

just remember rule: bracket or!

where foo = 'bar' , (sale.type != 2 or (sale.type = 2 , sale.customers != 0 ) ) , blah = 3 

actually condition can simplified to:

( sale.type != 2 or sale.customers != 0 )  

because logically checking sale.type = 2 redundant.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -