I got a table (games
) like this:
ID| title |category|rank
________________________
11|FIFA 17| ps3 | 3
22|FIFA 17| ps4 | 2
33|FIFA 17|xbox one| 4
44| GTA 5 | ps3 | 3
55| GTA 5 | ps4 | 2
66| GTA 5 |xbox one| 4
77|FIFA 16| ps3 | 3
88|FIFA 16| ps4 | 2
99|FIFA 16|xbox one| 4
I want all rows where title
contains FIFA
, but no duplicates! And ordered by rank
ASC
so this:
ID| title |category|rank
________________________
22|FIFA 17| ps4 | 2
88|FIFA 16| ps4 | 2
What I tried:
SELECT * FROM games WHERE title LIKE '%FIFA%' GROUP BY title ORDER BY rank ASC
and the duplicates from title
are getting removed but ORDER BY rank ASC
is complete ignored, the result is like:
ID| title |category|rank
________________________
11|FIFA 17| ps3 | 3
99|FIFA 16|xbox one| 4
EDIT:
I WANT ALL TITLES ONLY ONCE NAMELY WHERE THE RANK IS THE LOWEST!!!