SQL query Inner Join

Hello. I have a three table setup in my database: members, clases, classregistration.
The class registration table has m_id and c_id columns that store the member id and class id. For example if the same member registers with more classes it will be rows of same m_id with different c_id.
I am trying to view all members that are with a particular class and I have this query but it doesn’t return anything.

SELECT classregistration.c_id, members.member_first_name
	FROM classregistration
	INNER JOIN clases
	ON clases.class_id = classregistration.c_id
	WHERE clases.class_id = 2

What I am doing wrong?
Thanks

Solved…

 SELECT members.member_first_name, classregistration.c_id 
 FROM classregistration 
 INNER JOIN clases ON classregistration.c_id = clases.class_id
 INNER JOIN members ON members.member_id = classregistration.m_id
 WHERE classregistration.c_id = 1

This should get the job done :slight_smile:

1 Like

[quote=“Andrei_Birsan, post:5, topic:117593, full:true”]This should get the job done :slight_smile:
[/quote]

you can safely remove the join to the clases table

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.