我有三个名为 edum_application、edua_courseEvent 和 edua_coursePackage 的表。
我正在写一个问题以从 edum_application 获取所有应用程序,其中所有 courseEvent 的 coursePackage_id 都是 x 并且都具有相同的 applicationWrapper_id
这个查询有效,但它有效吗?
SELECT app.application_id, app.applicationWrapper_id
FROM edum_application AS app
INNER JOIN edua_courseEvent AS ce ON app.courseEvent_id = ce.courseEvent_id
WHERE app.applicationWrapper_id = 662
AND app.courseEvent_id IN
(
-- Is this really efficient?
SELECT ce.courseEvent_id
FROM edua_courseEvent AS ce
WHERE ce.coursePackage_id =
(
SELECT coursePackage_id
FROM edua_courseEvent AS ce
WHERE ce.courseEvent_id = 13377
)
)
输出:
application_id applicationWrapper_id
72643 662
72645 662
72646 662
72647 662