Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6367267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:31:36+00:00 2026-05-25T00:31:36+00:00

How can I relate a table with multiple records from another table? Basically, I

  • 0

How can I relate a table with multiple records from another table?

Basically, I have a table for an ‘event’, how do I keep track of which ‘users’ (in their own seperate table) are in a particular event? Right now I just have a column in the ‘event’ table with a comma separated list of the users IDs who have joined that ‘event’.

There must be a better way to do this…right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:31:37+00:00Added an answer on May 25, 2026 at 12:31 am

    Typically you have a table called users_in_event which holds one row for each user in a many-to-many relationship with the events table. So for each event, you will have a number of table rows mapped individually to users.

    CREATE TABLE users_in_event
    ( 
      user_id INT,
      event_id INT,
      FOREIGN KEY user_id REFERENCES users (user_id) ON UPDATE CASCADE,       
      FOREIGN KEY event_id REFERENCES events (event_id) ON UPDATE CASCADE
      -- Optionally, use ON DELETE CASCADE for the events foreign key
      -- FOREIGN KEY event_id REFERENCES events (event_id) ON UPDATE CASCADE ON DELETE CASCADE
    )
    

    To find out which users are in an event, do:

    SELECT 
      users_in_event.user_id,
      users.name
    FROM users JOIN users_in_event ON users.user_id = users_in_event.user_id
    WHERE event_id=1234;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database with various tables whose records can be tagged, so
If all tables I want to delete from have the column gamer_id can i
I have created a stored procedure to delete data from multiple tables. my work
I have i table users (id,name) and operations (id,date,id_user,id_target_user) if i didn't have the
I have a class that inherits a base class to which another class has
In Visual Studio as most of you will have noticed that related file can
Related to https://stackoverflow.com/questions/139944/where-can-one-find-free-software-icons-images I have a need for free weather-related icons. Specifically, I need
My question really has three related parts which I hope you can help me
We have a database with the time related data in it. As you can
Suppose I have a junction table EmployeeId DeptId --------- ------ 1 1 1 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.