MySQL Forums
Forum List  »  MySQL Query Browser

Multiple Queries Run from Query Browser and result store in miltiple csv files query wise
Posted by: Narender Kumar
Date: October 19, 2010 10:51PM

Hi there !!!

I have 10 MySql Queries.
I run them one by one in query browser and export the result in CSV format file.

Is there any way i can run all the queries from single query browser and the result output should store in there respective CSV files.

I tried to search google but have not found any clear instruction.
Below is what i found

C:\MySQL\bin>mysql --user=root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 81
Server version: 5.0.45-community-nt-log MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> USE community;
Database changed
mysql> SELECT `Name`, `Address`, `City`, `State`, `Zip`, `Phone`
-> FROM `persons`
-> WHERE `City` LIKE '%Los Angeles%'
-> ORDER BY `Name` ASC, `Zip` ASC
-> INTO OUTFILE 'los-angeles-persons.csv' FIELDS ESCAPED BY '""' TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';
Query OK, 299 rows affected (0.05 sec)



/* through command prompt */
C:\MySQL\bin>mysql --user=root --database=community --execute="SELECT `Name`, `Address`, `City`, `State`, `Zip`, `Phone` FROM `persons` WHERE `City` LIKE '%Los Angeles%' ORDER BY `Name` ASC, `Zip` ASC FIELDS ESCAPED BY '\"\"' TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n';" -p > los-angeles-persons.csv


/* using script */

C:\MySQL\bin>mysql --user=root -p < script.sql > los-angeles-persons.csv


Which is ok, but i have at least 10 such queries and i want the result set in 10 different CSV files.

Any help or pointers are much Appreicated.
Thanks in advance.

--NK

Options: ReplyQuote


Subject
Written By
Posted
Multiple Queries Run from Query Browser and result store in miltiple csv files query wise
October 19, 2010 10:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.