0
我有2個表MYSQL不存在工作不
courseobjects表
id_objects | type | id_type | completed | id_courses
41 |movie |25 |0 |27
42 |presentation|11 |0 |27
43 |movie |26 |0 |27
courseobjectsresults
id_courseresult | id_courseobject |id_user |result
92 |41 |62 |1
我想表明courseobjects表中的行,其中ID是不存在的 courseobjectsresults(id_courseobject)
我想:
SELECT * FROM courseobjects WHERE NOT EXISTS (SELECT * FROM courseobjectsresults WHERE courseobjectsresults.id_courseobject <> '41')
輸出我得到的是空,但它應該從courseobject顯示一行ID 42和43個
感謝。不存在
SELECT *
FROM courseobjects
WHERE NOT EXISTS (
SELECT 1
FROM courseobjectsresults
HERE courseobjectsresults.id_courseobject = courseobjects.id_objects
)
謝謝!有用! – Phoenix