1

这是一个 SQL 查询,如果 first- 返回多个值,则该查询失败

SELECT     subject
FROM         a_batchcourse_subject AS s
WHERE     (batchcourse =
                          (SELECT     batchcourse
                          FROM          a_course_batchcourse AS b
                          WHERE      (course = 'Course 1')))

在第一个查询可能返回多个值的情况下,编写此查询的正确方法是什么?

4

2 回答 2

5

你不想IN在 sql 中=

SELECT subject
FROM a_batchcourse_subject AS s
WHERE batchcourse IN
(SELECT batchcourse
FROM a_course_batchcourse AS b
WHERE course = 'Course 1')
于 2012-06-18T03:28:54.963 回答
4

JOININ从句快得多

SELECT  s.subject
FROM    a_batchcourse_subject s 
        INNER JOIN a_course_batchcourse b
        on s.batchcourse = b.batchcourse
WHERE   (b.course = 'Course 1')
于 2012-06-18T03:32:37.753 回答