jyushinx Posted November 2, 2007 Share Posted November 2, 2007 Hi, I am having an issue developing a query to fit a specific need I have. I know what I want to do conceptually, but I don't know how to translate it into SQL. Let me explain: I have a Users table. The Primary Key in this table is UserId. I also have an EventSignUp table. Basically, users can sign up for particular Events, so the Events table consists of a match up of UserId and EventId. What I am trying to do is retrieve all the users who have NOT signed up for a particular event. So given an EventId of 10, I would want to retrieve all the UserIds from the User table where there is not a match up of the UserId and 10 (the EventId) in the EventSignUp table. I hope this is clear enough. If anyone needs further explanation, just say so. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/75857-solved-select-results-not-in-a-table/ Share on other sites More sharing options...
teng84 Posted November 3, 2007 Share Posted November 3, 2007 select fields from table1 where usernames not in (select userid from events) returns all the user from table that dont have a user id from event Quote Link to comment https://forums.phpfreaks.com/topic/75857-solved-select-results-not-in-a-table/#findComment-383936 Share on other sites More sharing options...
jyushinx Posted November 3, 2007 Author Share Posted November 3, 2007 Excellent. Worked like a charm. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/75857-solved-select-results-not-in-a-table/#findComment-383938 Share on other sites More sharing options...
teng84 Posted November 3, 2007 Share Posted November 3, 2007 but next time please at least try it before asking Quote Link to comment https://forums.phpfreaks.com/topic/75857-solved-select-results-not-in-a-table/#findComment-383972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.