I have 2 tables, I'll call them categories and articles. I want to display the category names from category by the last_modified date of the article table. Here's an example of the setup Categories id | name | description Articles id | title | category_id | content | last_modified I've been interacting with MySQL for a while, but I only know what I've needed to do what I do, and this is well beyond what I know or even know how to look for. Basically, my goal is to display the category names DESC according to the last_modified time of the articles. Maybe something like this is the right direction? select distinct category_id from articles group by category_id order by last_modified desc then loop through the category table name?
You need an INNER JOIN: SELECT Categories.name FROM Categories INNER JOIN Articles ON Categories.id = Articles.category_id GROUP BY Categories.name ORDER BY Max(Articles.last_modified) DESC; PHP: