I am not even really sure how to search for this type of question, let alone tackle solving it. Please direct me if there are keywords to use for developing such a query, and thus searching for solutions already provided.
I have two tables - threads and comments.
thread table
thread_id | title | text |
---|---|---|
1 | Foobar | foo |
2 | Barfoo | bar |
comment table
comment_id | date | text | thread_id |
---|---|---|---|
1 | 1 | lorem | 1 |
2 | 2 | ipsem | 1 |
3 | 3 | gypsum | 2 |
4 | 4 | tippy | 2 |
Use - I want to show a sidebar on the front page of a site showing the latest comments. But I only want to show the most recent comment per each thread. Meaning, I want the result to look like this:
result
comment_id | text | thread_id |
---|---|---|
4 | tippy | 2 |
2 | ipsem | 1 |
Can anyone kindly point me to how I might go about searching for help / keywords on this type of query and/or direct help in what mysql syntax is necessary to do this kind of query please?
Thank you