12 lines
421 B
MySQL
12 lines
421 B
MySQL
|
/*7. Write a query to that appends strings to the selected fields, indicating whether or not a specified salesman was matched
|
||
|
to a customer in his city.*/
|
||
|
SELECT a.salesman_id, name, a.city, 'MATCHED'
|
||
|
FROM salesman a, customer b
|
||
|
WHERE a.city = b.city
|
||
|
UNION
|
||
|
SELECT salesman_id, name, city, 'NO MATCH'
|
||
|
FROM salesman
|
||
|
WHERE NOT city = ANY
|
||
|
(SELECT city
|
||
|
FROM customer)
|
||
|
ORDER BY 2 DESC;
|