aeboi80 Posted January 25, 2010 Share Posted January 25, 2010 Ok, here is what I am trying to do. I have the following SQL statement: SELECT * FROM `jx_members` WHERE `sponsor` LIKE '1300' This ends up return about 200 matching records. What I know need to do is take the results from this query and and find each record in the DB which has that records listed as their sponsor id, and then the same thing from that record set returned. That is probably a bit confusing and let me see if I can give an example to better explain that. Lets say, using my above SQL, that I search for every one in the DB that had their sponsor id field listed as 1300. Lets then say that return 2 matches. Lets again assume that those 2 mates have a mid (this is a unique field to each record, its essentially the user id) of 1400 and 1500 What I now need to do is go back to the database and query for all records which have a sponsor id of 1400 and the do the same for 1500(and so on if there were more than just 2 records returned in my example). Lets say that when we do the query for 1400 it returns a record with a mid of 1600. I would then need to repeat the above process above for this set of returned records. So numerically it would show as: 1300 1400 and 1500 have a sponsor id of 1300 1600 has a sponsor id of 1400 I assume the need of a loop is for sure and possibly an array to store the results from each query in, but I am a bit lost as to how to go about constructing the code to do this. I thought it would be an easy thing to do, but I am more of C# guy. Your help is greatly appreciate =) Chad Link to comment https://forums.phpfreaks.com/topic/189688-some-help-dealing-with-some-sql-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.