I need to fetch distinct values of a table, which has an auto-incremented id field. I need the id to identify, but I don't care which id when all values are the same except the id.
I came up with the following, which seems to work. Is there a better way to do this though?
SELECT id, date_f, date_t, num_n, num_d, mn, is
FROM t
GROUP BY date_f, date_t, num_n, num_d, mn, is
Another concern is, would this always return the same ids if the query is executed more than once?
EDIT:
Sample db:
id date_f date_t num_n num_d mn is
1 10 10 10 10 10 10
2 10 10 10 10 10 10
3 10 10 10 10 10 10
I want to store all of the columns of one row out of these. I don't care if the id is 1, 2 or 3 as long as it's the same the next time I execute the query (without adding/deleting any rows between). So far, two answers suggested using min(id)
which seems like a good idea.