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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.