Dear all,
I did a parametric export of selected tables of a database.
Following select works correctly.
SELECT * INTO OUTFILE ‘filename.csv’ FIELDS TERMINATED BY ‘;’ FROM tableName"
$sql_1 = “SELECT * INTO OUTFILE '”. $dest_file ."’ ". $outparam . "FROM ". $valori[$i];
sc_exec_sql($sql_1);
Now I would like to add to it also a first line with columns name separated with ‘,’ .
I’ve tried to use UNION but it give me an error about the nr of columns that are different .
Just to test it with a only table I did the following.
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = ‘calendar’
UNION
SELECT * FROM associations_mng.calendar
error: #1222 - The used SELECT statements have a different number of columns
It’s correct becouse first select is about 1 column with all columns names that they are 9 records,
the second is about 9 columns with some records. (1 vs 9)
Have you got an easy solution to have something like that as csv file in output
COL_NAME1, COL_NAME2, COL_NAME3, … COL_NAME n,
AAAAA, bbbbbb, CCCCC, … NNNNNN
AAAAA, bbbbbb, CCCCC, … NNNNNN
AAAAA, bbbbbb, CCCCC, … NNNNNN
In XLS it would be similar to make the reverse copy of first colum…
Bye
Thanks