craigeb78 Posted March 8, 2003 Share Posted March 8, 2003 I hope somebody will understand what I\'m asking and will be kind enough to give a response. Basically, lets say I have 3 tables, all containing information about users... user table: uid name lname 1 john fanny physical table: uid sex eye_color 1 1 4 interest table: uid hobbies preferences 1 text text (also have tables with color id\'s and sex id\'s but I guess it\'s not important at this point) What i\'m trying to do is a search via php where it will query the the physical table for the specified sex, obtain all those rows for uid, and then output information from the interest, physical and user table for each uid returned. I think i\'ve been staring at this stuff too long, and I\'m just lost. Anybody have any ideas where I can start? You\'re guidance on this would be greatly appreciated. -Craig Quote Link to comment Share on other sites More sharing options...
shivabharat Posted March 8, 2003 Share Posted March 8, 2003 select a.* , b.*,c.* from user as a,physical as b,intrest as b where a.uid = b.uid = c.uid and a.id = $supplied_value; Quote Link to comment Share on other sites More sharing options...
craigeb78 Posted March 8, 2003 Author Share Posted March 8, 2003 Thanks for the help on that. I think that will work eventually. I am having trouble though.. I guess its more complicated than i originally let on. The way I\'m trying to do it now, is the form is searching the profile table for sex and returning all uid\'s that match that sex: $sql = mysql_query("SELECT uid FROM profile WHERE sex=$sex") //Putting result to array while($uidarray = mysql_fetch_array($sql) { $uid = $uidarray[uid]; //then attempting to retrieve all infomation from 3 tables as you have showed me $sql2 = ("SELECT a.*, b.*, c.* FROM user AS a, profile AS b, interest AS c WHERE a.uid = b.uid = c.uid and a.uid=$uid"); //putting all returns into array (i\'m not sure if this is right) $result = mysql_fetch_array($sql2); $username = $result[username]; echo "$username"; } I\'m not sure of the best way to do what I\'m trying to do above, but $username isnt returning any value in this instance. Can ya tell me if the above should work or the best way to do it? Thanks a ton. Quote Link to comment 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.