我仍然不熟悉在db_design中实现连接,我不确定这个SQL是否有效。
"SELECT * FROM notes JOIN small_note ON notes_id = '$id' AND authname = '$author' AND bookname = '$book' AND user = '$username'"
这样更容易阅读:
"SELECT * FROM notes
JOIN small_note ON notes_id = '$id'
AND authname = '$author'
AND bookname = '$book'
AND user = '$username'";
答案 0 :(得分:7)
不,不是。
您需要为两个表指定连接列,并且需要确保使用正确的WHERE
子句(查询中缺少该子句)。
这可能更合适:
SELECT * FROM notes n
JOIN small_note sn
ON n.notes_id = sn.notes_id
WHERE notes_id = '$id'
AND authname = '$author'
AND bookname = '$book'
AND user = '$username'
答案 1 :(得分:0)
我认为您需要将第一个AND
替换为WHERE
。
答案 2 :(得分:0)
不,您的$ id应该是保存对另一个表的引用的列名。这不是变量,而是列名