Consider the following data.
STUDENT |
||||
StudentID |
SName |
Gender |
Age |
ClubID |
3234 |
Alfred Smith |
Male |
20 |
BSK |
2244 |
McJohnson Robert |
Male |
22 |
|
2389 |
Jessica Low |
Female |
20 |
JPA |
4211 |
Roland Devingo |
Male |
24 |
|
4383 |
Jane Usa Khan |
Female |
21 |
BKY |
4450 |
Elaine Fong |
Female |
20 |
JPA |
CLUB |
|||
ClubID |
CName |
Founded |
Budget |
BKY |
Bakery Club |
2010 |
2546 |
PDC |
Photomedia and Design |
2005 |
1345 |
JPA |
Japanese Anime |
2009 |
3453 |
BSK |
Basketball |
2011 |
6744 |
Write an SQL statement to display student name and club name in ascending order of the student name. Include all clubs even if they do not have any members.
Hi,
Please find the answer below:
----------------------------------------
SQL Query in MYSQL database:
SELECT SName, CName
FROM Student
RIGHT JOIN Club
ON Club.ClubID = Student.ClubID
ORDER BY SName;
In order to return all the rows from the Club table we need
to
right join the tables and order by student name.
-------------------------------
Hope this helps.
Let me know if you need more help with this.
Kindly, like the solution, if you find it useful.
Thanks.
Get Answers For Free
Most questions answered within 1 hours.