gloeilamp Posted May 22, 2007 Share Posted May 22, 2007 Hey guys, I'm quite the n00b with MySQL, I know how to make some basic queries but now I'm up for one where my head explodes.. ??? The Situation: I've got three tables: guests, filmfairs and fair_guests. The first is just a table with the information about each guest. So with a [you]guestID[you], name, url and a biography. The second has information about film fairs. [you]filmfairID[/you], title, date and a description. The last one is a table where the 2 are linked together. In order to add a guest to multiple filmfairs. It has the following records: [you]ID[/you], filmfairID and guestID. Everything works out fine. I can write the checked (I use checkboxes for the guest lists) guests into the "link-table", and I can retrieve the correct guests. But now the problem comes when trying re-add guests to the link-table. I want to generate a list with all the guests EXCLUDING the guests that are allready linked with that particular film fair. I tried several queries but I'm shooting blanks, I've don't have a good idea of where I should go with the query. So my question is, can anyone point me in the right direction? Thank you very much! Edit: for some reason I can't use the underline code because the letter is converted into the word "you". But the text between the [you][/you] is underlined and are the keys of those tables. Quote Link to comment https://forums.phpfreaks.com/topic/52495-solved-help-with-a-sql-query/ Share on other sites More sharing options...
Wildbug Posted May 22, 2007 Share Posted May 22, 2007 SELECT name FROM guests LEFT JOIN fair_guests ON guests.guestID=fair_guests.guestID AND fair_guests.filmfairID=0 WHERE fair_guests.ID IS NULL; Just replace fair_guests.filmfairID=0 with whichever number you want. Quote Link to comment https://forums.phpfreaks.com/topic/52495-solved-help-with-a-sql-query/#findComment-259290 Share on other sites More sharing options...
gloeilamp Posted May 22, 2007 Author Share Posted May 22, 2007 It seems that it is working fine when used in phpMyAdmin, but for some reason when I use it in my PHP coded page I just get all the results from the guest table. But anyway, the query seems to be working! That is great! Thank you very much, I'll try to debug my code first thing tomorrow. Quote Link to comment https://forums.phpfreaks.com/topic/52495-solved-help-with-a-sql-query/#findComment-259305 Share on other sites More sharing options...
gloeilamp Posted May 24, 2007 Author Share Posted May 24, 2007 The problem is solved! With help from Wildbug. I debugged my code and it work's like a charm! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/52495-solved-help-with-a-sql-query/#findComment-261009 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.