0

Let's say my database table structure is like :

he     haddress hage   she        saddress     sage
Sam      USA    25   Jenny      germany     21
John     UK     32   Anne       france      29
keith    USA    27   nicole     france      21

I want to export this aboce result set into a csv file using this command :

select he, haddress, hage, she, saddress, sage into outfile '/tmp/test1.csv' 
fields terminated by ','
lines terminated by '\n' from table_name;

it creates the csv file as following format :

Sam,USA,25,Jenny,germany,21
John,UK,32,Anne,france,29
keith,USA,27,nicole,france,21

now I want the above as below :

Sam,address,USA,age,25,knows,Jenny,address,germany,age,21
.....
.....
.....

how to pass these string while generating the csv file.

4

1 回答 1

0
select he, 'address', haddress, 'age',  hage, 'knows', she, 'address', saddress, 'age' sage into outfile '/tmp/test1.csv' 
fields terminated by ','
lines terminated by '\n' from table_name;
于 2013-10-11T09:43:48.197 回答