I selve SQL kan du gøre det ved at bruge UNION
. Og brug ORDER BY
for hele forespørgslen!
SELECT `title1` AS `title`, `type`
FROM `table`
UNION
SELECT `title2` AS `title`, `type`
FROM `table`
ORDER BY `title` ASC
Output
+-------+------+
| TITLE | TYPE |
+-------+------+
| asd1 | 7 |
| asd2 | 7 |
| qwe1 | 3 |
| qwe2 | 3 |
+-------+------+