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

  • SEARCH
  • Home
  • 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 7655381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:30:07+00:00 2026-05-31T12:30:07+00:00

I have three tables in my database: reservations , events and users . I

  • 0

I have three tables in my database: reservations, events and users. I want to display all the users that subscribed to a certain event. The tables are linked via the following method:


SELECT users.u_name, events.e_id, events.e_title
FROM users
INNER JOIN reservations
ON reservations.r_s_id = users.u_id
INNER JOIN events
ON reservations.r_event_id = events.e_id

I need to join the reservation table because the field reservations.r_s_id correlates with the unique id of the user (users.u_id) and then the field reservations.r_event_id correlates with the unique id of the events (events.e_id). This was the only method i could come up with to approach all the necessary values.

It is my goal to get an output like below but have no clue how to achieve this

Event 1
 - user 1
 - user 3
 - user 9
Event 2
 - User 2
 - User 5
 - User 12

I tried using GROUP_CONCAT() and GROUP BY on events.e_title but that did not resulted the way i want it to

Anybody an idea?

  • 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-31T12:30:09+00:00Added an answer on May 31, 2026 at 12:30 pm

    Select from reservations, order the result set by events.e_id and print a new heading each time the event changes.

    Like this:

    $SQL = "SELECT users.u_name, events.e_id, events.e_title
    FROM reservations
    INNER JOIN events
    ON reservations.r_event_id = events.e_id
    INNER JOIN users
    ON reservations.r_s_id = users.u_id
    ORDER BY events.e_id";
    
    $res = mysql_query($SQL);
    
    $last_event = NULL;
    
    while ($row = mysql_fetch_assoc($res)) {
    
        // check if curser moved to new event
        if (!$last_event || $last_event <> $row['e_id']) {
    
            // output heading for event
            echo $row['e_title'], '<br />', PHP_EOL;
    
            // remember ID of current event
            $last_event = $row['e_id'];
        }
    
        // output attendee
        echo '- ', $row['u_name'], '<br />', PHP_EOL;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three database tables: users emails invitations Emails are linked to users by
I have a database with three tables: user_table country_table city_table I want to write
I have three database tables with foreign keys to each other, and I want
I have three tables in my database: Events, Jobs, and CollectableEntities. Events has a
I have three tables in an SQL 2005 database, that I need to query
I have three tables in my database: What I want is to get items
I have three tables in my sample database: Users ID Username Password Roles ID
I have three database tables: users , user_profiles and friends : users id username
I have three tables in my database. A users table, StoreA and StoreB StoreA
Imagine this scenario: I have three tables in my database: Products , Users and

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.