I have articles table, article_comments.
I want to get the value: last_modified_all of article. I need this value to be the great date of this two:
- the last_modified field of articles table.
- the last comment of article_comments last_modified column.
Can someone help me? the structure is very simple, and you can guess is without problem.
This is the greatest-n-per-group problem that comes up frequently on Stack Overflow. Here’s how I solve it:
This has a chance of producing more than one row per article unless
article_comments.last_modifiedis unique. To resolve this, use a tiebreaker. For instance, if there’s an auto-incrementing primary key column: