OMG I'm going crazy. Multiple Join Help!
Posted: Thu Jun 10, 2010 3:22 pm
I've been trying to figure this out for days. Can someone help me???
Ok, so a user logs in creating a $_SESSION['userName']. This user has the ability to sign up for an event from a list of events. The problem I'm having is I need the user to only be presented with the events he HASN'T signed up for yet.
3 Tables: Users(Primary Key=userName), Events(Primary Key=eventID), and UsersEvents(Keys=userName and eventID).
So I need to come up with a sql statement along the lines of "SELECT eventIDs that's not associated with $_SESSION['userName'] in the UsersEvents table"
This is what I've tried:
"SELECT Events.eventID, UsersEvents.eventID FROM Events, UsersEvents WHERE UsersEvents.eventID != Events.eventID AND UsersEvents.userName != '".$_SESSION['userName']."'"
It's does not work. I'm not very experienced with joins.
Any help would be freakin awesome.
Ok, so a user logs in creating a $_SESSION['userName']. This user has the ability to sign up for an event from a list of events. The problem I'm having is I need the user to only be presented with the events he HASN'T signed up for yet.
3 Tables: Users(Primary Key=userName), Events(Primary Key=eventID), and UsersEvents(Keys=userName and eventID).
So I need to come up with a sql statement along the lines of "SELECT eventIDs that's not associated with $_SESSION['userName'] in the UsersEvents table"
This is what I've tried:
"SELECT Events.eventID, UsersEvents.eventID FROM Events, UsersEvents WHERE UsersEvents.eventID != Events.eventID AND UsersEvents.userName != '".$_SESSION['userName']."'"
It's does not work. I'm not very experienced with joins.
Any help would be freakin awesome.