On 3/7/06, C.R.Vegelin <[EMAIL PROTECTED]> wrote:

> Hi Ariel,
>
> Maybe this example helps you to create CSV output from MySQL.
> The first SELECT generates the headerline; the second the data.
> ( SELECT 'FieldA','FieldB','FieldC', ... )
> UNION
> ( SELECT `FieldA`, `FieldB`, `FieldC`, ...
> INTO OUTFILE 'D:/MySQL Datafiles/myFile.csv'
> FIELDS TERMINATED BY ','
> LINES TERMINATED BY '\r\n'
> FROM ... ...
> GROUP BY `FieldA`, `FieldB`, `FieldC`, ...
> );
>
> Don't forget the braces ( and ).
> HTH, Cor


So, to all the SQL wizards out there...

How would one perform this same operation, but using the INFORMATION_SCHEMA
virtual db to provide the column headings in the first row rather having to
hand type them as shown above?

Bonus marks for beginning the line with a #....

My attempt stalled as soon as I got one column of data in the result set
with a row for each column of the target table.

SELECT COLUMNS FROM INFORMATION_SCHEMA WHERE TABLE_SCHEMA = 'test' AND
TABLE_NAME = 'testtable'

Ideas?

TIA,
-jp

Reply via email to