i have a table of users and a table of activities. each user can be related to a few activities when i enter an activity, i need display the user list and vice versa how can i make that connection? if i seperate the ids by commas, i won't be able to make a selection by id
You would use 2 tables: user_table user_id other_columns activities_table activity_id user_id activity_name You can then add as many activities as you want for each user. You can do a Join to connect the activities of each user.
I see. It would be a little different then. activities_table activity_id activity_name user_table user_id other_columns user_activities ua_id activity_id user_id
You can use a JOIN to get this information very easily. It looks more complicated, but storing as a csv prevents MySQL from being able to use the data. To get activities: SELECT activities_table.activity_name FROM activities_table LEFT JOIN user_activities ON activities_table.activity_id = user_activities.activity_id WHERE user_activities.user_id = ''; To get users: SELECT user_table.user_name FROM user_table LEFT JOIN user_activities ON user_table.user_id = user_activities.user_id WHERE user_activities.activity_id = '';