sql | SoloLearn: Learn to code for FREE!

0

sql

You need your customer's names, along with the names of the cities in which they live. The names of the cities are stored in a separate table called "cities".

2/22/2018 2:48:21 PM

Debashish Mahapatra

12 Answers

New Answer

+8

SELECT customers.name, cities.name FROM customers RIGHT OUTER JOIN cities ON cities.id=customers.city_id;

+2

brother plzz tell me after so many attempts i am not getting the correct answer

+1

You haven't really asked a question. If there's a table called "customers", that contains "id", "name" and "city_id" and a table called "cities" that contains "Id" and "name", then selecting all the customer names along with their cities can be made by: select customers.name, cities.name from customers inner join cities on cities.id = customers.city_id But I'm not sure if that's what you want. For example you may wanna right join the cities if there may be NULLs.

+1

The below is the correct answer it is showing but i think the answer is wrong.. select customers.name, cities.name from customers right outer join cities on cities.id = customers.city_id Can anyone explain the answer to me ? Thanks,Regards

0

Do I?

0

brother plzz tell me the sql challenge part 2 of qs 5 answer

0

Oh, now I get what you're asking about. Anyway, I almost got the exact answer to that right. It should be: select customers.name, cities.name from customers right outer join cities on cities.id = customers.city_id I don't know what is SL policy on posting the solutions like this, while afaik all the questions already have hints and stuff. If this answer violates some code, moderators are free to do whatever they are free to do...

0

ok thank you but it is wrong answer

0

https://ibb.co/ngyzoH

0

ALTER ADD

0

SELECT customers.name, cities.name FROM customers RIGHT OUTER JOIN cities ON cities.id=customers.city_id;

0

SELECT customers.name, cities.name FROM customers RIGHT OUTER JOIN cities ON cities.id=customers.city_id;