I have this table
Column1|Column2
1 2
3 4
I want to merge two columns and make them appear like this
NewColumn
1
The keyword you're looking for is UNION:
SELECT column 1 AS newColumn
FROM...
UNION
SELECT column2 AS newColumn
FROM...
ORDER BY newColumn
This of course gets unwieldy if you need to combine multiple columns - ideally avoid having to do it by storing data as raw as possible and aggregating instead.
Maybe you could use UNION
:
SELECT Column1 FROM table UNION SELECT Column2 FROM table
Not sure to understand if that's what you want...
I would advice to do this using php or some script but not using mysql. Still, you can achieve this with mysql like this:
SELECT t1.Column1 FROM table as t1
UNION
SELECT t2.Column2 as column1 FROM table as t2 ORDER BY Column1;