All I have table in MySQL as bellow.
+---------+-------------+---------------+ | item_no | item_name | item_location | +---------+-------------+---------------+ | ITM145 | laptop | USA | | ITM146 | camera | USA | | ITM147 | cd | USA | | ITM148 | phone | USA | | ITM149 | cd | France | | ITM150 | phone | France | +---------+-------------+---------------+
The last tow items location is France, and the same items I have in USA, I want the query to return me as bellow exclude same value for location France.
+---------+-------------+---------------+ | item_no | item_name | item_location | +---------+-------------+---------------+ | ITM145 | laptop | USA | | ITM146 | camera | USA | +---------+-------------+---------------+
First try
SELECT * FROM table WHERE item_location !='France' GROUP BY item_name
FAIL second try
SELECT * FROM table
WHERE item_location NOT IN('France')
GROUP BY item_name