mysql - turn two sql joins into a double join? possible? -


i have 2 separate sql joins. 1 getting project name , other class name 2 different tables same id.

a table called pupilproject holds id, projectid , classid in project table project name , class table class name.

is there way of doing single query? appreciated!

//get project name $getproject = mysql_query("select project_name projects join pupilproject using     (project_id) pupil_project_id = '".$id."'"); while ($row = mysql_fetch_array($getproject)) { $thisproject = $row['project_name']; }  //get project class name $classname = mysql_query("select class_name class join pupilproject using     (class_id) pupil_project_id = '".$id."'"); while ($row = mysql_fetch_array($classname)) { $pclass = $row['class_name']; } 

use following sql in code:

"select project_name, class_name pupilproject left join projects using (project_id) left join class using (class_id) pupil_project_id = '".$id."'" 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -