mySQL table loses column structure when exported as CSV format

154
December 26, 2017, at 7:08 PM

I am trying to export a table from MariaDB to a folder in CSV format. In MariaDB program, I entered the query: MariaDB [testdatabase]> SELECT * from datatable into outfile '/tmp/exportf.csv'; I then managed to locate this exported file. However, on opening the csv file with Excel, I find that the data are all clustered onto one column. These should be organised into 7 columns. How can I modify my query to avoid this issue?

Answer 1

try this,

SELECT * from datatable into outfile '/tmp/exportf.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' ;
READ ALSO
Mysql - select random 4 data from a column, distinct by 2 different columns

Mysql - select random 4 data from a column, distinct by 2 different columns

I'm trying to select 4 different random data from a table on Mysql but I want some fields unique, for example;

139
Disable PAY Button when status “paid”

Disable PAY Button when status “paid”

I want to disable pay button when status paid

141
MySQL Select the field as Distinct having data type as Text with filtering

MySQL Select the field as Distinct having data type as Text with filtering

If we have a table T1 with a field named orders have data type as Text

130
Mysql Optimization suggestion for large table

Mysql Optimization suggestion for large table

i want to optimize this query,

122