bobbyv102 Posted June 19, 2006 Share Posted June 19, 2006 Hello,As the post states I am fairly new to PHP. I am working on a database in MS SQL and what I am trying to do is use a PHP web page to pull data from it. The original script works to pull from one table, but now I need it to pull from 3 seperate tables.The database stores:1. list of instructors = tblInstructors -Instructor id = eeid - instructor first name = fname - instructor last name = lname2. list of Classes = tblSchedule -Course id = id - instructor name = fname - start date = Date -end date = EndDate3. the survey responses = tblPostClassSurvey - 12 different survey question fields - survey id = id - course id = CourseIDI need all the results from post class survey, but only of the name of the instructor which is stored in the php variable $instructor, and the date grouped by the date. Unfortunately I do not have the code I have used so far here at home, but a point in the right direction will help. I found several resources that used the join option and pulling my fields with dot notation (ie: tblSchedule.id) but that does not return anything. Any help woul dbe great help.ThanksRobert Link to comment https://forums.phpfreaks.com/topic/12355-help-with-query-to-multiple-tables/ Share on other sites More sharing options...
klaroen Posted June 19, 2006 Share Posted June 19, 2006 I think you just need to do a few queries... Link to comment https://forums.phpfreaks.com/topic/12355-help-with-query-to-multiple-tables/#findComment-47221 Share on other sites More sharing options...
radalin Posted June 19, 2006 Share Posted June 19, 2006 It's more then a database question then a php problem I think. You could use a query like:[code]SELECT tb1.id,tb2.id,tb3.id FROM tb1,tb2,tb3 WHERE tb1.id=tb2.id[/code]where in this code tb1 stands for table names. You could use such a query. Or It seems that you have some where clauses which use some values pulled from db. You could such a query:[code]SELECT id FROM tb1 WHERE id IN ( SELECT id FROM tb2 WHERE id IN ( SELECT id FROM tb3 WHERE fname='myname' ) )[/code]id will take values which the in statement returns and if our in statement return 2 and 3 our code will be like:[code]SELECT id FROM tb1 WHERE id = 2 OR id = 3[/code]Is this helps? Link to comment https://forums.phpfreaks.com/topic/12355-help-with-query-to-multiple-tables/#findComment-47228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.