SQL Exercises: Find the salesmen and customers with their name and cities, who belongs to the same city
SQL JOINS: Exercise-1 with Solution
Write a SQL statement to prepare a list with salesman name, customer name and their cities for the salesmen and customer who belongs to the same city.
Sample table: salesman
Sample table: customer
SELECT salesman.name AS "Salesman", customer.cust_name, customer.city FROM salesman,customer WHERE salesman.city=customer.city;
Output of the Query:
Salesman cust_name city James Hoog Nick Rimando New York James Hoog Brad Davis New York Pit Alex Julian Green London Mc Lyon Fabian Johnson Paris Nail Knite Fabian Johnson Paris Pit Alex Brad Guzan London
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?