I have a list of integers that contains duplicate values, such as 1, 2, 2, 3, 3, 4, 5, 6
. Is there a way, using MySQL, to SELECT
a list of unique values (1, 2, 3, 4, 5, 6
in this case)?
I realize it can be done by creating and inserting into a temporary table:
BEGIN;
CREATE TEMPORARY TABLE temp (value INT);
INSERT INTO temp VALUES (1), (2), (2), (3), (3), (4), (5), (6);
SELECT GROUP_CONCAT(DISTINCT value) FROM temp;
DROP TEMPORARY TABLE temp;
ROLLBACK;
but is there a way that does not require a temporary table?
The list of integers is not coming from another MySQL table; pretend it is hard-coded.