I have the following database:
id | remote_id | title | description
-------------------------------------
1 | 12341234 | test | test-description
2 | 4535234 | blah | testestetetst
3 | 12341234 | test | test-description2
4 | 3454656 | qsffq | testqfsfqgfgsdffgfd
I'm trying to select the description (and ONLY the description) of each unique remote_id. The 'winning' description should be the highest id. like this:
id | remote_id | title | description
-------------------------------------
2 | 4535234 | blah | testestetetst
3 | 12341234 | test | test-description2
4 | 3454656 | qsffq | testqfsfqgfgsdffgfd
using the following code returns each unique remote_id correctly
SELECT DISTINCT(remote_id) FROM table ORDER BY id DESC
but this returns the duplicates
SELECT DISTINCT(remote_id),description FROM table ORDER BY id DESC
How do can I filter distinct values on remote_id, but only select the description with the highest id in my query?
any help would be greatly appreciated!
EDIT 1: formatting
EDIT 2: using following version: 5.7.27-0ubuntu0.18.04.1
SELECT version();
and report the result of this query please.distinct
is not a function, and it applies to all columns in the select list.