$ mysql -u mysqlusername -e 'insert your sql here'
On Mon, 1 Nov 2004, Scott Haneda wrote:
My query works:
(version 4)
SELECT u.id, r.user_id,
u.first_name, u.middle_name, u.last_name,
u.company, u.department, u.address, u.address2,
u.city, u.state, u.country, u.zip,
My query works:
(version 4)
SELECT u.id, r.user_id,
u.first_name, u.middle_name, u.last_name,
u.company, u.department, u.address, u.address2,
u.city, u.state, u.country, u.zip,
u.phone, u.fax, u.email,
DATE_FORMAT(u.updated, '%m/%d/%Y'), DATE_FORMAT(u.added,
There are lots of ways to do it. My personal favorite is to write it in
Perl with the DBI library and tell cron to run that Perl script ... your
Perl script could then write the data in any format you see fit, even
send it somewhere else using Net::FTP or whatever.
Just my $0.02...
-id
Scott
You could write a bash script like this:
#!/bin/bash
mysql -u username -ppassword --exec=SELECT...; textfile.txt
There's no space after -p and before the password. This will export the
results to a simple text file. It might not be in format you want
though. But, it gives you an idea of
Scott Haneda wrote:
My query works:
(version 4)
SELECT u.id, r.user_id,
u.first_name, u.middle_name, u.last_name,
u.company, u.department, u.address, u.address2,
u.city, u.state, u.country, u.zip,
u.phone, u.fax, u.email,
DATE_FORMAT(u.updated, '%m/%d/%Y'),
Daniel Kasak wrote:
Write your script with the following line at the top:
tee /path/to/output/file.sql
Actually thinking about this more, you can probably skip this bit and
just direct your output from the command called by cron, as per
Spenser's example.
ie:
mysql -u username -ppassword