Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Subselektieren oder nicht subselektieren?

Versuchen Sie, IN als Inline-abgeleitete Tabelle in die FROM-Klausel zu verschieben

SELECT 
    id_topic, id_member_comment, pd.username, dt_post
FROM
   (
   SELECT MAX(last_id_comment) AS id_comment
   FROM forum_topic 
   GROUP BY cat_id
   ) AS foo
   JOIN
   forum_comment c ON foo.id_comment = c.id_comment --AND a cat_id join too?
   LEFT JOIN
   persondata pd ON c.id_member_comment = pd.id_member;