My setup of the two tables is as follows:
Table 1
+ ------ + --------- + -------------------------------- ------ +
| id | tail | content |
+ ------ + --------- + -------------------------------- ------ +
| 1 | abc | ... |
| 2 | def | ... |
| 3 | ghi | ... |
| 4 | def | ... |
| 5 | jkl | ... |
+ ------ + ------- + ---------------------------------- ------ +
table 2
+ ------ + -------- + --------------------------------- ------ +
| id | tailID | value | others |
+ ------ + -------- + --------------------------------- ------ +
| 1 | 2 | 412 | |
| 2 | 3 | 215 | |
| 1 | 2 | 571 | |
| 1 | 4 | 123 | |
+ ------ + -------- + --------------------------------- ------ +
I like to get all the columns from these two tables in a row with matching tail = tailID, but not with duplicate rows that have the same tail.
For a duplicate TAIL, you just need to get one max VALUE line of the 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 the same tail.
hightes VALUE 2.