嗨,我正在学习教程并苦苦挣扎,因为我已经收到了消息:
Unknown column 'conversations_members' in 'where clause'
我已经搜索并查看了,只是无法弄清楚如何解决这种情况。
这是我的三张表:
对话
conversation_id | conversation_subject
对话成员
conversation_id | user_id | conversation_last_view | conversation_deleted
对话消息
message_id | conversation_id | user_id | message_date | message_text
这是对我造成问题的查询。
$sql = "SELECT
`conversations`.`conversation_id`,
`conversations`.`conversation_subject`,
MAX(`conversations_messages`.`message_date`) AS `conversation_last_reply`
FROM `conversations`
LEFT JOIN `conversations_messages` ON `conversations`.`conversation_id` = `conversations_messages`.`conversation_id`
INNER JOIN `conversations_members` ON `conversations`.`conversation_id` = `conversations_members`.`conversation_id`
WHERE `conversations_members`= `{$_SESSION['user_id']}`
AND `conversations_members`.`conversation_deleted` = 0
GROUP BY `conversations`.`conversation_id`
ORDER BY `conversation_last_reply` DESC";
$result = mysql_query($sql);
$conversations = array();
while (($row = mysql_fetch_assoc($result)) !== false) {
$conversations[] = array(
'id' => $row['conversation_id'],
'subject' => $row['conversation_subject'],
'last_reply' => $row['conversation_last_reply']
);
}
return $conversations;
在进行功能之前,我有一个die(mysql_error());
错误,如果您需要完整的功能代码,我可以提供。
有人可以帮助解释我哪里出错了,为什么?
干杯
..ps 你会建议什么?