+ 1

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".

22nd Feb 2018, 2:48 PM
Debashish Mahapatra
Debashish Mahapatra - avatar
13 Respostas
+ 11
SELECT customers.name, cities.name FROM customers RIGHT OUTER JOIN cities ON cities.id=customers.city_id;
10th Apr 2018, 10:44 AM
Mahnoor Shahzad
Mahnoor Shahzad - avatar
+ 2
brother plzz tell me after so many attempts i am not getting the correct answer
22nd Feb 2018, 3:04 PM
Debashish Mahapatra
Debashish Mahapatra - avatar
+ 2
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.
22nd Feb 2018, 3:11 PM
deFault
+ 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
24th Feb 2019, 5:36 PM
Sumanth N S
Sumanth N S - avatar
0
Do I?
22nd Feb 2018, 3:01 PM
deFault
0
brother plzz tell me the sql challenge part 2 of qs 5 answer
22nd Feb 2018, 3:44 PM
Debashish Mahapatra
Debashish Mahapatra - avatar
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...
22nd Feb 2018, 3:59 PM
deFault
0
ok thank you but it is wrong answer
22nd Feb 2018, 5:05 PM
Debashish Mahapatra
Debashish Mahapatra - avatar
22nd Feb 2018, 5:09 PM
deFault
0
ALTER ADD
29th Nov 2019, 7:17 AM
Sayali Shedge
0
SELECT customers.name, cities.name FROM customers RIGHT OUTER JOIN cities ON cities.id=customers.city_id;
22nd Apr 2020, 8:28 PM
Kashif Saleem
Kashif Saleem - avatar
0
SELECT customers.name, cities.name FROM customers RIGHT OUTER JOIN cities ON cities.id=customers.city_id;
11th Sep 2020, 8:28 PM
OjeifoIduma
0
Write a query to display student ID and number of course registered by students. Display student ID only if student has registered for a course. Give alias name for the count as NOOFCOURSES.   Sort the result based on count in descending and student ID  ascending.
27th Apr 2021, 5:05 PM
Renu Sri
Renu Sri - avatar