How to Inverse Where Clause in mysql Query?

Code_Tesh :

I'm querying my MySQL "consumer_details" table where the age is > 30 and purchase_count > 100, by the same time I need to exclude the people who age is equal ( = ) 50 and purchase_count < 100

I'm running the following query right now :

Base Query :

SELECT * 
    FROM `consumer_details` 
    WHERE `age` > 30 AND `purchase_count ` > 100 
    ORDER BY `gender` DESC

Extended Query :

SELECT * 
    FROM `consumer_details` 
    WHERE `age` > 30 AND `purchase_count ` > 100  
         NOT IN (`age` = 50 AND `purchase_count ` < 100 ) 
    ORDER BY `gender` DESC
juergen d :
SELECT * 
FROM consumer_details 
WHERE   (age > 30 AND purchase_count > 100)
AND NOT (age = 50 AND purchase_count < 100) 
ORDER BY gender DESC

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=386146&siteId=1