question

JamalHa889 avatar image
JamalHa889 asked

How can I show the employees and customers that are from London and Winnipeg, the statement must be in the select statement.

That's the question i need to do :

For each row retrieved, show which employees or customers are from London and Winnipeg by embedding London and Winnipeg in the SELECT statement.

Thats what i a putted but the output is not what i want :

SELECT First_Name, Last_Name, (SELECT City FROM employees WHERE City = 'London' OR 'Winnipeg'), Customers_Name, Customers_LastName, (SELECT Customers_City FROM customers WHERE Customers_City = 'London' OR 'Winnipeg') FROM employees, customers WHERE City = 'London' OR 'Winnipeg' and Customers_City = 'London' OR 'Winnipeg'

sqlmysql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jon Crawford avatar image
Jon Crawford answered

that seems unnecessarily complicated, rather than just returning the city/customers_city for the items in your WHERE condition. Try using a CASE Statement, CASE WHEN city = 'London' THEN 'London ELSE 'Winnipeg' END, something like that.

Seems pointless though.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.