我正在尝试编写 SQL 语句,但遇到了麻烦。我有以下表格
笔记
person_user VARCHAR
message VARCHAR
time DATETIME
id INT (primary Key)
人
name (primary key)
address VARCHAR
telephone INT
有关联
person_associating VARCHAR
person_associating_with VARCHAR
我需要出现笔记,只有表格中写person_associating_with
的笔记。Associated_With
这是我现在的尝试:
SELECT *
FROM Notes
INNER JOIN Notes.person_user ON Notes.id AS associatedMessages
INNER JOIN Associated_With On associatedMessages
WHERE
Person.name = person_associating
ORDER BY
time DESC;
目前,无论查询如何,我都会返回所有可能的结果