In my table is plenty of rows, I prepare test_result_table:
SELECT * FROM
(
SELECT ID, DATA
FROM table
WHERE DATA = "A" OR DATA = "B" OR DATA = "C"
) AS test_result_table
How I can do this:
SELECT * FROM
(
SELECT 1 AS RESULT, ID
FROM test_result_table
WHERE DATA = "A"
UNION
SELECT 2 AS RESULT, ID
FROM test_result_table
WHERE DATA = "B"
UNION
SELECT 3 AS RESULT, ID
FROM test_result_table
WHERE DATA = "C"
) AS result_id
ORDER BY RESULT
I know to do with temp table, is any better (faster) solution?
I expect (x = some ID):
RESULT |ID
1 |x
1 |x
2 |x
2 |x
3 |x