----- Original Message -----
From: "Payne" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Friday, May 05, 2006 12:09 AM
Subject: Output to a file
Hey,
been trying to output a select statment to a file, all the books I have
only show how to input from a file, what is the correct way....
I thought I could do select * from my_toy >> `/tmp/my_toys`
But I get an error.
Here is a snippet from some documentation about MySQL which I wrote for
myself. It shows a different technique for capturing output from a batch
file into an output file; if the batch file contains 'select * from my_toy',
it will capture the output in a file. It's not exactly what you want but
maybe it will be "close enough".
Running a script from OS prompt
If you are connected to the database and are at an OS prompt, use this
pattern:
mysql < batch-file > output-file
For example, if I want to run a script or batch file named my_batch_file.sql
and write the output of the script to a file named my_batch_file.out, I'd
need to do this:
mysql < my_batch_file.sql > my_batch_file.out
If you are NOT connected to the database, use this pattern:
mysql -u username -p < batch_file > output_file
For example, if your user name is 'fred' and your password is 'dino' and you
want to run a script or batch file named my_batch_file.sql against database
'barf' and write the output to a file called my_batch_file.out, you'll need
to do this:
mysql barf -u fred -p < my_batch_file.sql > my_batch_file.out
[Be sure to supply the password when prompted.]
--
Rhino
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.4/332 - Release Date: 04/05/2006
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]