| Article: |
SQL Subqueries | |
| Subject: | subqueries | |
| Date: | 2003-05-15 11:32:27 | |
| From: | anonymous2 | |
|
how do you do a subquery where you are using a composite primary key for example:
|
||
Showing messages 1 through 1 of 1.
| Article: |
SQL Subqueries | |
| Subject: | subqueries | |
| Date: | 2003-05-15 11:32:27 | |
| From: | anonymous2 | |
|
how do you do a subquery where you are using a composite primary key for example:
|
||
Showing messages 1 through 1 of 1.
SELECT
courseID
, studentID
FROM
whatever W
WHERE
EXISTS (
SELECT
1 -- doesn't matter what you return here, even NULL is OK, the EXISTS operator is satisfied as soon as anything is returned
FROM
somewhereelse S
WHERE
S.courseID = W.courseID
AND S.studentID = W.studentID
)
Another option would be to do an inner join on the two columns, but that's not a subquery so beyond the scope of this discussion :)