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 9090797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:27:31+00:00 2026-06-16T22:27:31+00:00

I have 4 tables that I need to pull data from. I need to

  • 0

I have 4 tables that I need to pull data from. I need to count how many people are signed for a single event and see if a user is applied for an event.

These are my table setups:

TABLE: users
+----+----------+-------+--------+-------+
| id | username | level | class  | guild |
+----+----------+-------+--------+-------+
| 1  | example1 | 100   | Hunter | blah  |
| 2  | example2 | 105   | Mage   | blah2 |
| 3  | example3 | 102   | Healer | blah  |
+----+----------+-------+--------+-------+
ID is primary

TABLE: event_randoms
+----+----------+-------+--------+----------+----------+
| id | username | level | class  | apped_by | event_id |
+----+----------+-------+--------+----------+----------+
| 1  | random1  |  153  | Hunter |    3     |    3     |
| 2  | random2  |  158  | Healer |    3     |    1     |
| 3  | random3  |  167  | Warrior|    1     |    3     |
+----+----------+-------+--------+----------+----------+
ID is primary
apped_by should be foreign key to users.id
event_id should be foreign key to events.id

TABLE: events
+----+------------+------------+-----------+-----------+-----------+
| id | event_name | event_date | initiator | min_level | max_level |
+----+------------+------------+-----------+-----------+-----------+
| 1  |   event1   |    date1   |     1     |    100    |     120   |
| 2  |   event2   |    date2   |     1     |    121    |     135   |
| 3  |   event3   |    date3   |     1     |    100    |     120   |
| 4  |   event4   |    date4   |     1     |    150    |     200   |
+----+------------+------------+-----------+-----------+-----------+
ID is primary

TABLE: event_apps
+----+----------+--------------+
| id | event_id | applicant_id |
+----+----------+--------------+
| 1  |    3     |      2       |
| 2  |    4     |      2       |
| 3  |    3     |      1       |
| 4  |    1     |      3       |
+----+----------+--------------+
ID is primary
event_id should be foreign key to events.id
applicant_id should be foreign key to users.id

I will be the first to admit that I am very new to this. I just learned how to use MySQL a few days ago. I can grab stuff from a single table, but I am unsure how to grab from multiple tables.

This is the SQL query I tried

SELECT DD_events.id, event_id, applicant_id, guild, level, class, DD_users.id
      FROM DD_events, DD_event_apps, DD_users
      WHERE DD_event_apps.event_id = DD_events.id
      AND DD_event_apps.applicant_id = DD_users.id

and tried to print_r an array but the array turns up empty.

So a few questions pertain to this:
1: How would I count and display as a number how many people (users and randoms) are signed up for an event?
eg: event 3 should have 4 total (2 users and 2 randoms)

2: How do I see if a particular individual is signed for an event and display text based if they are or not?
eg: user 1 is signed up for event 3 so it would be “Registered” but user 2, who is not signed, would display “Not Registered”

3: I want to display info for who is signed for a particular event in 2 tables, 1 for users and another for randoms.
eg: Event 3 would have 2 users info (username, guild, class, level) under the users table and then 2 random users info (name, class, level, what user applied this person) in the random table.

Any and all help is appreciated even if you can answer 1 part.

  • 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-06-16T22:27:33+00:00Added an answer on June 16, 2026 at 10:27 pm

    I’m thinking this would be your base query:

    SELECT
        event.id,
        app.applicant_id,
        usr.guild,
        usr.level,
        usr.class,
        usr.id AS Userid
    FROM
        DD_events event
    JOIN
        DD_event_apps app
        ON  (event.id = app.event_id)
    LEFT JOIN
        DD_users usr
        ON  (app.user_id = usr.id)
    

    You can make modifications to this to aggregate it, like so:

    SELECT
        event.id,
        COUNT(app.applicant_id) AS ApplicantCount,
        COUNT(DISTINCT usr.guild) AS UniqueGuilds,
        COUNT(DISTINCT usr.level) AS UniqueLevels,
        COUNT(DISTINCT usr.class) AS UniqueClasses,
        COUNT(DISTINCT usr.id) AS UniqueUsers
    FROM
        DD_events event
    JOIN
        DD_event_apps app
        ON  (event.id = app.event_id)
    LEFT JOIN
        DD_users usr
        ON  (app.user_id = usr.id)
    GROUP BY
        event.id
    

    I could write those scripts for you, but I think this provides a good starting point for you to continue from. You’ll find that T-SQL is fairly simple when you are trying to get the results you are looking for. Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables described below. What I need is a single query that
I need to pull a large amount of data from various tables across a
I need to pull data from two tables: Neptune_FN_Analysis and Neptune_prem There will be
I have an Excel workbook that contains several spreadsheets. I need to pull data
I have the following tables: http://www.gulllakeschools.net/mysqltables.pdf I need to pull the data out in
I have built an iPhone app that needs to pull data from a server.
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I have a couple of tables that need to be be joined. The tables
I have 2 tables in a DB with very similar schemas that need to
I have a two tables that are Subject and chapter . I need to

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.