I have successfully exported my table in MySQL to csv with columns. I used this guy's answer at Include headers when using SELECT INTO OUTFILE?
SELECT 'ColName1', 'ColName2', 'ColName3'
UNION ALL
SELECT ColName1, ColName2, ColName3
FROM YourTable INTO OUTFILE '/path/outfile'
However, I want to export a query formula as a new column to be added to the csv file. I tried adding an extra calculated column after the second SELECT statement. MySQL gave me an error saying "The used SELECT statements have a different number of columns".
Example formula: SELECT CAST((ColName1 * ColName2) AS DECIMAL(7,2)) AS ColNameX. I'm not sure where to input it in my export statement.