我如何结合这些查询? “已删除”字段是指示主题何时被“删除”的时间戳。该主题并未真正被删除。如果它有实际的时间戳,我就不会显示它。
$topics = "SELECT id FROM topics WHERE deleted = '0000-00-00 00:00:00'";
$comments = "SELECT * FROM comments WHERE topic_id IN($topics)";
答案 0 :(得分:2)
使用此解决方案:
SELECT a.*
FROM comments a
INNER JOIN topics b ON
a.topic_id = b.id AND
b.deleted = '0000-00-00 00:00:00'