MySQL - AND / OR logic - what's wrong? -


i can't figure out what's wrong query. want productids specific sellers no longer valid. "valid," product has active='y' , expiredate>=now() , statusid = 20 (among several other not valid).

here's query

    select distinct(productid) products     sellerid in     (/*list of sellerids*/)      , (active != 'y' or statusid != 20 or expiredate < now()) 

and example data (all sellerids in subquery above)

    productid | active | statusid | expiredate     1         |   y    |     20   | 2015-08-01     2         |   n    |     20   | 2015-08-01     3         |   y    |     0    | 2015-08-01     4         |   y    |     20   | 2015-07-01 

i expect 2, 3 , 4 result.

so in problem statement says need , between active, statusid , expiredate. please use below query:

select distinct(productid) products sellerid in (/*list of sellerids*/)  , active != 'y' , statusid != 20 , expiredate < now() 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -