Just asking is it possible in php to perform sql statment’s in 1 function.
What my sql really does is fetch data from three tables in my database.
I am currently unsure of what method to use. Inner join would pop into it but i forgot what the proper syntax. so i was thinking about this.
$qry_display = "SELECT student_id,
section_id,level,photo,address,father_occupation,father_phone,father_company,mother_occupation,
mother_phone,mother_company
from tbl_er
where student_id='$id' AND level="3rd Year"";
The above statement would retrieve the information from tbl_er these would be the students history.
$qry_display = "SELECT fname,
sex,
lname,
mname,
birth_date,
birth_place,
address,
father,
father_degree,
mother,
mother_degree,
from tbl_enroll where student_id='$id'";
The above statement would retrieve part of the information from tbl_enroll these would be the students core unchangeable data. Also the first statement has “section_id” to be retrieved. so my idea is to retrieve that value so it would be used for the last sql which is.
$qry_display = "SELECT section_name,adviser_id,schoolyr
from tbl_section
where student_id='$id' AND section_id='$sid'";
and my idea to on how to get the section_id is before the last statement i would put.
$sid= section_id (I am unsure if this will work.)
Also will this statement trigger all three statements in one function?
$sql_display = mysql_query($qry_display) or die (mysql_error());
Thank you, Appreciate any feedback.
There is a lot wrong with this, and you probably will not get what you are looking for even if you work out the bugs, so lets start with writing this as 1 coherent query with left joins (good call btw).
The last join doesn’t care about the student_id because the section / advisor relationship does not depend on a student.