In SQL zelf kun je het doen met UNION
. En gebruik ORDER BY
voor de hele zoekopdracht!
SELECT `title1` AS `title`, `type`
FROM `table`
UNION
SELECT `title2` AS `title`, `type`
FROM `table`
ORDER BY `title` ASC
Uitvoer
+-------+------+
| TITLE | TYPE |
+-------+------+
| asd1 | 7 |
| asd2 | 7 |
| qwe1 | 3 |
| qwe2 | 3 |
+-------+------+