Answer the question
In order to leave comments, you need to log in
How to get rid of logical error in SQL query?
Hello! There is a database with customers. I want to understand which customers live in the same city. Decided to use a left join.
Here is the request itself:
Select C1.Name, C2.Name, C1.City
FROM Customers AS C1, Customers AS C2
WHERE C1.City = C2.City
AND C1.Name <> C2.Name
ORDER BY C1.Name DESC;
+---------------------------------+---------------------------------+------------------+
| Name | Name | City |
+---------------------------------+---------------------------------+------------------+
| Евгений Щербаков | Олег Щербаков | Saint Petersburg |
| Олег Щербаков | Евгений Щербаков | Saint Petersburg |
+---------------------------------+---------------------------------+------------------+
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question