+ 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".
13 Réponses
+ 11
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
+ 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.
+ 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
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;
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.