Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个mysql问题。我有两张表,一张称为表格,另一张称为记录。记录是每个表格的记录。我可以将多个记录与表单 ID 关联。但是,并非所有表单都有与之关联的记录。我想找到所有没有记录的表格。
我能做的最好的就是这个
SELECT * FROM forms JOIN records WHERE forms.form_id != records.form_id
但是我最终得到了一百万多条记录,我知道这是不正确的。
尝试LEFT OUTER JOIN:
LEFT OUTER JOIN
SELECT * FROM forms LEFT OUTER JOIN records ON forms.form_id = records.form_id WHERE records.form_id IS null
SELECT * FROM forms WHERE form_id NOT IN ( SELECT form_id FROM records )