SELECT table content to file

SELECT table content to file

SELECT table content to file in Mysql:

Using SELECT … INTO OUTFILE query,We can SELECT and writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax. you should use a command such as mysql -e “SELECT …” > file_name to generate the file on the client host.

Syntax:
[SELECT query] INTO OUTFILE [file_name];

Example:

1. SELECT * from students where mark1>75 INTO OUTFILE “first_class.txt”;

2. mysql -u root -p -h 192.168.0.9 school -e “SELECT * from students where mark1 > 75″ > “first_class.txt”;

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.