私は行方不明だが、私のSQLステートメントは1行を返すだけです。SQL結合のみ1行を返します
SELECT
tl.*,
(tl.topic_total_rating/tl.topic_rates) as topic_rating,
COUNT(pl.post_id) - 1 as reply_count,
MIN(pl.post_time) AS topic_time,
MAX(pl.post_time) AS topic_bump
FROM topic_list tl
JOIN post_list pl
ON tl.topic_id=pl.post_parent
WHERE
tl.topic_board_link = %i
AND topic_hidden != 1
ORDER BY %s
私は2つのテーブル(post_listとtopic_list)、およびtopic_listのtopic_idにpost_listのpost_parentリンクを持っています。
すべてのトピック(そのボードのtopic_board_linkがnの場合)を返す代わりに、1つのトピックのみを返します。
PK/FK定義を含む、CREATE TABLEの関連部分をポストします。 – Ronnis
post_listのPKはpost_idであり、topic_listのPKはtopic_idである。私はFKを持っていない(私は思う)。 –