MySQL Forums
Forum List  »  Newbie

Accessing data from 3 tables in one query
Posted by: Dave Bevis
Date: August 07, 2005 01:50PM

Have an application for creating resumes built with Mysql and PHP. One table "JL_SchoolFromResumes" has data about the school user attended. In that table an id number is stored for their degree type which pulls the degree name from the "Degrees" table. An id (LocalLawSchool) is also stored for schools selected from a drop down list which then pulls the school name from the "JL_LawSchools" table. There is also another field for school name if it is not in the "JL_LawSchools" table.

My problem is trying to retrieve both the degree name and the school name in a select query. I have tried several different versions of a select query but I either only get the school info that uses a name from list or I get every school in the table regardless of user.


SELECT JL_SchoolsFromResumes.SchoolID, JL_SchoolsFromResumes.UserID, JL_SchoolsFromResumes.SchoolName, JL_SchoolsFromResumes.City, JL_SchoolsFromResumes.State, JL_SchoolsFromResumes.DateStartedYear, JL_SchoolsFromResumes.DateGraduatedYear, JL_SchoolsFromResumes.DegreeID, JL_SchoolsFromResumes.OtherStudyArea, JL_SchoolsFromResumes.Awards, JL_SchoolsFromResumes.Comments, JL_SchoolsFromResumes.LocalLawSchool, Degrees.Degree, JL_LawSchools.LocalSchoolName FROM JL_SchoolsFromResumes, Degrees, JL_LawSchools WHERE (((JL_SchoolsFromResumes.DegreeID = Degrees.DegreeID) AND (JL_SchoolsFromResumes.LocalLawSchool = JL_LawSchools.SchoolID)) AND (JL_SchoolsFromResumes.UserID = %s))

I have tried every variation I can think of in the WHERE part of this select statement but can't get it to work right. Any help on this would be greatly appreciated.

Thanks.

Dave

Options: ReplyQuote


Subject
Written By
Posted
Accessing data from 3 tables in one query
August 07, 2005 01:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.