bncplix Posted October 11, 2009 Share Posted October 11, 2009 Okay so first I will give you a rundown of the structure, then ask my question Table 1: Friend status. Contains the friend id of one person then the friend id of who they have added as a friend. Table 2: All the different friends What I need to do is make a query that will select the people from table 2, that do not have an entry in table 1 So the table 1 structure may be ID userid friendid Where: ID is just the general entry Userid is the main user id Friend id is the person they ahve added Table 2 may have: ID Username Password hasfriended It should only select those from table2 that have hasfriended as 0. I am not too great at combining queries like this. Can anybody point me in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/177356-multi-table-help/ Share on other sites More sharing options...
bncplix Posted October 11, 2009 Author Share Posted October 11, 2009 Ohh and I will paypal the first person that helps me and it ends up working $2 Quote Link to comment https://forums.phpfreaks.com/topic/177356-multi-table-help/#findComment-935137 Share on other sites More sharing options...
bncplix Posted October 11, 2009 Author Share Posted October 11, 2009 ( i cant edit) Nevermind, I think i got it. Quote Link to comment https://forums.phpfreaks.com/topic/177356-multi-table-help/#findComment-935139 Share on other sites More sharing options...
bncplix Posted October 12, 2009 Author Share Posted October 12, 2009 Okay it turns out I did not solve it. First, I will show you my query: SELECT system.id ,system.username ,system.password ,system.followed ,follows.userid ,follows.systemid FROM system INNER JOIN follows WHERE system.followed=0 AND system.id != follows.systemid ORDER BY RAND() LIMIT 10 Basically, i need it to select a group of members from the system table, that have the "followed" field set to 0. Also, it has to check the follows table and makesure that the new id's it is selecting from the system table are not already listed in the follows table with the same userid So here is my structure: Table: System id username password followed Table: Follows id userid systemid So basically, my query must select the amount from system. But the ones selected in system must have followed=0. It also must check the follows table to makesure that there is no insersion already that has the same userid and systemid as the new ones it is grabbing. Any help? Quote Link to comment https://forums.phpfreaks.com/topic/177356-multi-table-help/#findComment-935156 Share on other sites More sharing options...
fenway Posted October 17, 2009 Share Posted October 17, 2009 How is the output from that query different than what you would expect? Quote Link to comment https://forums.phpfreaks.com/topic/177356-multi-table-help/#findComment-938824 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.