Piping MySql Output
- Use “mySql -vvv -uuser -ppwd < someInput.sql > someoutput.log”
Another way is to simply put the .SQL script into an editor, like notepad. I use MYSQL Query Browser.
Hit CTL-A to select all and hit COPY.
Then paste this into the mySQL command window (dos box).
If you include the tee c:\myfile.txt command (or whatever file you're using) it will put all the info into that file. Make the last command in the .sql file notee.
If you want to see warnings and errors you'll have to include SHOW WARNINGS for the details.
like this:
tee J:\Temporary\xtest.txt
use test;
drop table if exists xtest; create table xtest (name varchar(100), description varchar(100));
insert into xtest values (“Item 1”, “this is just text”); insert into xtest values (“Item 2”, “this is just <b>text</b>”); insert into xtest values (“Item 3”, “this is just text”); insert into xtest values (“Item 4”, “this is just <b>text</b>”); insert into xtest values (“Item 5”, “this is just text”); insert into xtest values (“Item 6”, “this is something else”); insert into xtest values (“Item 7”, “this is something else”); insert into xtest values (“Item 8”, “this is something else”); insert into xtest values (“Item 9”, “this is something else”); insert into xtest values (“Item 10”, “this is something else”);
select * from xtest;
SELECT a.name FROM (
SELECT name FROM xtest WHERE description LIKE "%text%"
) a LEFT JOIN (
SELECT name FROM xtest WHERE description LIKE "%<b>text</b>%"
) b ON a.name=b.name WHERE b.name IS NULL;
notee
It's like you just typed it all in at the command prompt…