Mysql
 sql >> Database >  >> RDS >> Mysql

Come combinare due colonne MySQL in una colonna?

In SQL stesso puoi farlo usando UNION . E usa ORDER BY per l'intera domanda!

SELECT `title1` AS `title`, `type`
FROM `table`
UNION
SELECT `title2` AS `title`, `type`
FROM `table`
ORDER BY `title` ASC

Uscita

+-------+------+
| TITLE | TYPE |
+-------+------+
|  asd1 |    7 |
|  asd2 |    7 |
|  qwe1 |    3 |
|  qwe2 |    3 |
+-------+------+

Fiddle:http://sqlfiddle.com/#!2/ff9cf/1