Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting table with SequelPro into csv file

I'm trying to export a MySQL table into csv file using SequelPro, however the result file is not properly formatted. For instance, on the first column should the id, in some of the records there is a number, but in others there is text instead. This happens in pretty much every column.

One explanation might be that the field are being exported vertically rather than horizontally (you have the id 1 on the first row and the id 10 on the 10th row.

Maybe I'm getting the the options (fields) wrong, in which case I'd appreciate help.

What I need is for the file to have the titles as the first row and the actual data in the subsequent rows with each data property as a column.

Appreciate the help

PS: I've tried this but I'm getting the data vertically as well.

like image 530
WagnerMatosUK Avatar asked Jun 24 '15 15:06

WagnerMatosUK


1 Answers

For convenience in executing and sharing across the team, consider adding commas as the part of SELECT statement itself like this

 SELECT
    col1 as 'Column 1',',',
    col2 as 'Column 2',',',
    col3 as 'Column 3',',',
    col4 as 'Column 4',',',
    col5 as 'Column 5',',' 
 FROM
    table1, table2
 WHERE
    clause1 and clause2

The data and headers do automatically get their necessary commas.

like image 87
nehem Avatar answered Oct 21 '22 20:10

nehem