If you don't, then use
DISTINCT.GROUP BY in MySQL sorts results. You can even do:SELECT u.profession FROM users u GROUP BY u.profession DESC
and get your professions sorted in
DESC order.DISTINCT creates a temporary table and uses it for storing duplicates. GROUP BY does the same, but sortes the distinct results afterwards.
So
SELECT DISTINCT u.profession FROM users u
is faster, if you don't have an index on
profession.http://stackoverflow.com/questions/581521/whats-faster-select-distinct-or-group-by-in-mysql
沒有留言:
張貼留言