SQL: Filter records using not in operator
SQL Wildcard & Special Operator : Exercise-3 with Solution
Write a query to produce a list of salesman_id, name, city and commision of each salesman who live in cities other than Paris and Rome.
Sample table: salesman
SELECT * FROM salesman WHERE city NOT IN('Paris','Rome');
SELECT * FROM salesman WHERE NOT city IN('Paris','Rome');
Output of the Query:
salesman_id name city commission 5001 James Hoog New York 0.15 5005 Pit Alex London 0.11 5003 Lauson Hen San Jose 0.12
Pictorial presentation :
Query Visualization for Sample Solution:
Query Visualization for alternate Sample Solution:
Contribute your code and comments through Disqus.
Previous: Write a query to filter those salesmen with all information who comes from any of the cities Paris and Rome.
Next: Write a query to sort out those customers with all information whose ID value is within any of 3007, 3008 and 3009.
What is the difficulty level of this exercise?