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 Quote Link to comment 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... Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.