I've been searching for a way to correct my queries after the last MySQL update. I understand the Group By column isn't unique but I can't figure out how to update the query to comply with the strict rule and still retain the result I'm looking for. Does anyone have a suggestion?
SELECT
$SQLTable_Posts.`post_id`,
$SQLTable_Posts.`profile_id`,
$SQLTable_Posts.`post_title`,
$SQLTable_Posts.`post_slug`,
$SQLTable_Posts.`post_date`
FROM $SQLTable_Posts
WHERE $SQLTable_Posts.`post_date` > DATE_SUB(NOW(), INTERVAL 24 HOUR)
GROUP BY $SQLTable_Posts.`profile_id`
ORDER BY $SQLTable_Posts.`post_date` DESC
I would like to simply return the latest post made by each profile. For example, my database looks like this;
<table><tbody><tr><th>post_id</th><th>profile_id post_date</th><th> </th></tr><tr><td>0001</td><td>0001</td><td>2019-03-12 00:00:00</td></tr><tr><td>0002</td><td>0002</td><td>2019-03-12 00:00:00</td></tr><tr><td>0003</td><td>0001</td><td>2019-03-12 01:00:00</td></tr><tr><td>0004</td><td>0004</td><td>2019-03-12 00:00:00</td></tr></tbody></table>
I would like the results to return this;
<table><tbody><tr><th>post_id</th><th>profile_id post_date</th><th> </th></tr><tr><td>0003</td><td>0001</td><td>2019-03-12 01:00:00</td></tr><tr><td>0002</td><td>0002</td><td>2019-03-12 00:00:00</td></tr><tr><td>0004</td><td>0004</td><td>2019-03-12 00:00:00</td></tr></tbody></table>