My two table setup is like below:
table1
+------+---------+--------------------------------------+ | id | tail | content | +------+---------+--------------------------------------+ | 1 | abc | ... | | 2 | def | ... | | 3 | ghi | ... | | 4 | def | ... | | 5 | jkl | ... | +------+-------+----------------------------------------+
table2
+------+--------+---------------------------------------+ | id | tailID | value | others | +------+--------+---------------------------------------+ | 1 | 2 | 412 | | | 2 | 3 | 215 | | | 1 | 2 | 571 | | | 1 | 4 | 123 | | +------+--------+---------------------------------------+
I like to get all columns from this two tables in a row with matched tail = tailID but not duplicate rows which has same tail.
For the duplicate TAIL, just need to get the single row of max VALUE of same tail.
I am currently using
SELECT table1.tail, table2.other_column FROM table1 INNER JOIN table2 on table1.id = table2.tailID WHERE table1.some_coloum = "a sepecific string" ORDER BY table2.value
But it returns many duplicates of same tail.
I just need to have single row for duplicate TAIL with hightes VALUE of table2.