To start, I've just spent 12 hours straight trying to figure out how this works and I've learned lots of terms and definitions but I can't get it right. I've researched:
- One to many relationship
- Loops
- Arrays
- Joins
and much more!
What I want to achieve is to show all the projects in a list, next to the project name I want to show the project leader and all the participants for each project if any exists.
So the database structure right now:
DB: PROJECTS
PROJECT_ID PROJECT_NAME PROJECT_LEADER
1 MY PROJECT 1
2 UPDATE THIS 1
3 STATUS FIX 2
DB: USERS
USER_ID USER_FIRSTNAME
1 ADAM
2 BRIAN
DB: PARTICIPANTS
PARTICIPANT_ID PROJECT_ID USER_ID
1 1 2
And the SQL QUERY:
SELECT *
FROM PROJECTS P
JOIN users u ON p.project_leader = u.user_id
This is what I get when running the query:
MY PROJECT - ADAM
UPDATE THIS - ADAM
STATUS FIX - BRIAN
What I would like to see is this:
MY PROJECT - ADAM & BRIAN
UPDATE THIS - ADAM
STATUS FIX - BRIAN
Any help would be worth gold! Big thanks in advance.