Question

Consider the following data.    STUDENT StudentID SName Gender Age ClubID 3234 Alfred Smith Male 20...

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.

Homework Answers

Answer #1

Hi,

Please find the answer below:
----------------------------------------

  • Identify the common column between the tables.
  • CludID is the common column. ClubID in the Club table is the primary key that is referencing the ClubID in the Student table.
  • Then We need to Join the tables based on the Join condition.

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions