Adalat  Khan

Adalat Khan

  • 983
  • 1.3k
  • 480.4k

Store different query results into different Sheets of the same excel

Nov 26 2020 6:43 AM
Hi,
I have three queries that generates three different excel files on the disk and store the queries results in three different excell files. Following is my Queries:
 
SELECT * FROM Table1
INTO OUTFILE 'C:\\SFTP_ROOT\\MicrowaveLan.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
SELECT * FROM Table2
INTO OUTFILE 'C:\\SFTP_ROOT\\MicrowaveLanTX.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
SELECT * FROM Table3
INTO OUTFILE 'C:\\SFTP_ROOT\\MicrowaveLanRX.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
 
Actually i want to create a single excell file in the specified path and want to store the result of each query in the same excel file in different sheets for example, the result of Table1 will go to Sheet1, the result of Table2 will go to Sheet2 and the result of Table3 will go to Sheet3. Also i need to rename Sheet1 as Table1, Sheet2 as Table2, and Sheet3 as Table3.
Currently my files are in CSV format but i want to store them in a single excel file 
 
How can i do it please help. Thanks 
 

Answers (3)