MySQL Forums
Forum List  »  General

Issue with SQL JOIN and subquery
Posted by: Jack Wayne
Date: February 14, 2005 12:23PM

Hi,
I am having some issues generating the SQL for the following db structure

***** Table 1 *****
+--------------+
|course
+--------------+
|cid PK
|c_name
|ctype_id FK
+--------------+

**** Table 2 *****
+--------------+
|course_type
+--------------+
|ctype_id PK
|ctype_name
+--------------+

***** Table 3 *****
+-----------------+
|student_course
+-----------------+
|s_id FK
|c_id FK
+-----------------+

SELECT c_id,c_name FROM course LEFT JOIN course.ctype_id = course_type.ctype_id WHERE c_id NOT IN (SELECT c_id FROM student_course WHERE s_id = 1) ;

The subquery returns an empty set, and an error is generated.

I have tried many different combinations with no success any assistance would be great.

Thanks for the assistance
Jack

Options: ReplyQuote


Subject
Written By
Posted
Issue with SQL JOIN and subquery
February 14, 2005 12:23PM


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.