Database table with multiple value

Hello. I am trying to create a function that wold allow me to register gym members to gym classes. I do understand searching on the web that I would need a third table to store this data, as one gym class can have many members.
The new table will be called class registration and will have two columns: class_id and member_id that will be taken from the main members and classes table.
Also after having this new table I could perform operations like, retrieving all member_id that have registered with a particular class_id, or entering a class_id I could see all registered members.
Is this the right approach to the problem, and how I should formulate mysql statement for example to get the member details from the original members table, registered with a particular class.

Thank you for any help or suggestions.

[quote=“Andrei_Birsan, post:1, topic:117447, full:true”]
Is this the right approach to the problem[/quote]
yes

SELECT cr.member_id , m.name , m.hatsize FROM class_registration AS cr INNER JOIN members AS m ON m.id = cr.member_id WHERE cr.class_id = 937

1 Like

@r937 Thanks :wink:

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