"Jake Peavy" <[EMAIL PROTECTED]> wrote on 03/14/2006 01:52:28 PM:
> On 3/10/06, Jake Peavy <[EMAIL PROTECTED]> wrote: > > > > 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 > > > > > > Nobody has any ideas at all? (sheds solitary tear) > > -jp Nope, no suggestions. You are mixing purposes (not to mention data types) when you add column names to the output of INTO OUTFILE. Have you looked at using the CSV storage engine or mysqldump as alternatives? Shawn Green Database Administrator Unimin Corporation - Spruce Pine