I wanted to get the column_names of the tables when output to csv file when combining two tables with union and below is the one i have tried export. I know there is a question regarding this but that doesnot suit my requirement and hence seeking for help.
Note: Dont close this issue
select GROUP_CONCAT(CONCAT("'",COLUMN_NAME,"'"))
from INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 't1,t2'
AND TABLE_SCHEMA = 'database'
UNION ALL
select * from table t1 LEFT JOIN table t2 on t1.result=t2.result order BY ORDINAL_POSITION limit 5 INTO OUTFILE '/tmp/result.csv';
I am not sure if this is the rightway but i have big column lists.