0

I need to query two tables in my MySQL database. Here is the short overview: 2 tables: articles and article_logs. I have somethink like 2700 articles and each article can have from 20 to 50 logs. I would like to display for each article the last log date. The problem is that the query takes forever to be executed.

I am trying somethin like that:

SELECT articles.id, article_logs.date FROM articles
LEFT JOIN ( SELECT MAX(id), hash_key, date FROM logs GROUP BY id ) c 
ON article.hash_key = c.hash_key

Do you have an idea on how to do this in a proper and efficient way.

Thank you very much in advance.

4

1 に答える 1