Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join Problem 1

Status
Not open for further replies.

dagger2002

Programmer
Joined
Nov 23, 2004
Messages
172
Location
US
Here is the basic query with no joins. But it is giving me a 1064 error.

I am running mysql 4

Code:
SELECT 
     school.cdsCode, school.dist_cdsCode, school.sname, 

     class.clas_id, class.clas_semester, class.clas_sMonth, 
     class.clas_sDay, class.clas_eMonth, class.clas_eDay,      
     class.clas_sTime, class.clas_eTime, class.clas_dayM, 
     class.clas_dayT, class.clas_dayW, class.clas_dayTH, 
     class.clas_dayF, class.clas_dayS, class.clas_blo, 
     class.clas_active, class.cour_id, class.schoo_cdsCode, 
     
     course.cour_id, course.cour_name, course.cour_active 

WHERE 
     class.cour_id = course.cour_id AND 
     class.schoo_cdsCode = 
     school.cdsCode AND class.clas_id = 4 

ORDER BY course.cour_name

Can any one tell me my error?
 
No 'From'?

From class, course, school
WHERE
class.cour_id = course.cour_id AND
class.schoo_cdsCode =
school.cdsCode AND class.clas_id = 4
 
no join?
Code:
  FROM class
INNER
  JOIN course
    ON course.cour_id = class.cour_id 
INNER
  JOIN school
    ON school.cdsCode = class.schoo_cdsCode
 WHERE class.clas_id = 4



r937.com | rudy.ca
 
yes, it does, but why would you write them old style when the new style is so much better :-)

r937.com | rudy.ca
 
I dunno. But OP was using old style syntax. Didn't wanna confuse the issue :D
 
neither is the OLD style, the first is list syntax and is a poor way to learn to do joins, partcularly as joins get more complex. it is easier to leave conditions out of your join when you do it that way.

unfortunately mysql manual emphasizes using those types of joins even though it is easier to make errors with them.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top