mjcoco Posted May 22, 2008 Share Posted May 22, 2008 I never really learned how to properly join tables, i did find a way to hack together some sql for it to work together anyway. Here is what i have. $q = "SELECT * FROM Homework h, University s, department d, course c, professors p where h.Universe = s.id AND h.Depart = d.dept_id AND h.Cour = c.course_id AND h.Prof = p.prof_id"; Which will produce the correct information needed however when i run $result = mysql_query($q,$conn); while ($a = mysql_fetch_array($result)) It runs twice. My main question is the first code... I know i should use a join however im not sure exactly how it goes. Something like this? ??? SELECT * FROM Homework INNER JOIN University WHERE Univers=id INNER JOIN department WHERE Depart = depat_id Second could my while statement be running twice because i dont have properly joined tables? Or is there an error in the query itself? Thanks, Quote Link to comment Share on other sites More sharing options...
mjcoco Posted May 22, 2008 Author Share Posted May 22, 2008 Forgot to mention the output comes out odd also... out put example outone outone outtwo outtwo Quote Link to comment Share on other sites More sharing options...
mjcoco Posted May 22, 2008 Author Share Posted May 22, 2008 Ok so i added SELECT DISTINCT h.File and it got rid of the odd error, sorry for all the reply's was too long before i could use the modify. 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.