SQL advanced -> Sometime subquery perfectly serves the aim

The mission is to create phone list of customers that lives in the same city as Jessica Simpson.

The query involves subquery that returns only one value, and most of DBMS are supposed to execute it quickly:
SELECT CustomerID, CustomerName, phone1
FROM Customers
WHERE CustomerName <> 'Jessica Simpson'
AND City =
  (SELECT City
  FROM Customers
  WHERE CustomerName='Jessica Simpson')

Yet if you like JOINs, you can do it joining two replicas of Customers table:
SELECT a.CustomerID, a.CustomerName, a.phone1
FROM Customers AS a INNER JOIN Customers AS b
ON a.City = b.City
WHERE b.CustomerName='Jessica Simpson'
AND a.CustomerName<>'Jessica Simpson'

The result will be like this in both cases:
CustomerIDCustomerNamephone1
4Pestiana Oliviera354-523147
10Erika Nass354-257413
18Eugenio Banderas354-654789
.........


sqlexamples.info