So I have four tables in my database, and I'm extracting information from two of them. The first is the events table, which lists the EventID, EventName etc.... and the EventHostID. And then I have my attendance table, which looks like this:
It has as its primary key the ID from the event and the ID from the user table, and from this table I can find out who is invited to, maybe going or going to an event.
I have four SQL statements to extract the information I want:
SELECT EventID, EventName, EventLocation, StartDate FROM events WHERE EventHostID = 0
SELECT COUNT(UserID) AS Invited FROM attendance WHERE EventID = "1" AND EvStatus = "invit"
SELECT COUNT(UserID) AS Maybe FROM attendance WHERE EventID = "1" AND EvStatus = "maybe"
SELECT COUNT(UserID) AS Going FROM attendance WHERE EventID = "1" AND EvStatus = "going"
The result of the first COUNT statement is in as follows:
Invited table i.e. a count of how many people are invited. The two other count statements are in this format.
What I want is to be able to combine the results of these four SQL statements but I'm not sure how to construct the syntax. I want something that looks like this:
-----------------------------------------------------------------------------
| EventID | EventName | EventLocation | StartDate | Invited | Maybe | Going |
-----------------------------------------------------------------------------
| 0 | Party | Dave's house | 08/08/17 | 20 | 5 | 17 |
-----------------------------------------------------------------------------
| 2 | Wedding | Castle | 02/02/19 | 25 | 20 | 10 |
-----------------------------------------------------------------------------