w3resource
SQL exercises

SQL UNION Exercises: Display all salesmen and customer located in London

SQL UNION: Exercise-1 with Solution

1. Write a query to display all salesmen and customer located in London.

Sample table: Salesman


Sample table: Customer


Sample Solution:

SELECT salesman_id "ID", name, 'Salesman'
FROM salesman
WHERE city='London'
UNION
(SELECT customer_id "ID", cust_name, 'Customer'
FROM customer
WHERE city='London')

Sample Output:

ID	name	?column?
3001	Brad Guzan	Customer
3008	Julian Green	Customer
5005	Pit Alex	Salesman

Practice Online


Inventory database model

Query Visualization:

Duration:

Query visualization of Display all salesmen and customer located in London - Duration

Rows:

Query visualization of Display all salesmen and customer located in London - Rows

Cost:

Query visualization of Display all salesmen and customer located in London - Cost

Contribute your code and comments through Disqus.

Previous: SQL UNION Exercises Home
Next: Write a query to display distinct salesman and their cities.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming