Jump to content

[SOLVED] Join help


mjcoco

Recommended Posts

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,

Link to comment
https://forums.phpfreaks.com/topic/106722-solved-join-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.