How to save MySQL query output to excel or txt file

0 votes
How do you save output of a MySQL query to a MS Excel sheet?

Even if it's only possible to store the data in a .txt file, it will be okay.
Aug 20, 2020 in PHP by kartik
• 37,520 points
3,925 views

1 answer to this question.

0 votes

Hello @kartik,

You can write following codes to achieve this task:

SELECT ... FROM ... WHERE ... 
INTO OUTFILE 'textfile.csv'
FIELDS TERMINATED BY '|'

It export the result to CSV and then export it to excel sheet.

Hope it helps!!

Thank you!!

answered Aug 20, 2020 by Niroj
• 82,880 points

Related Questions In PHP

0 votes
1 answer

How Do I Get the Query Builder to Output Its Raw SQL Query as a String?

Hello @kartik, Use the toSql() method on a QueryBuilder instance. DB::table('users')->toSql() would return: select * ...READ MORE

answered Jul 22, 2020 in PHP by Niroj
• 82,880 points
1,054 views
0 votes
1 answer

How to see indexes for a database or table in MySQL?

Hello @kartik, To see the index for a ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,880 points
150,307 views
0 votes
1 answer

How to convert timestamp to date in MySQL query?

Hello @kartik, Try this: DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,880 points
7,841 views
0 votes
1 answer

How to Import SQL file into mysql?

Hello @kartik, From the mysql console: mysql> use DATABASE_NAME; mysql> ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,880 points
860 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
22,957 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
2,968 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
2,900 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
44,397 views
0 votes
1 answer

How to output MySQL query results in CSV format?

Hello @kartik, Using this command columns names will ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,880 points
2,523 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,336 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP