Page 1 of 1

IF statement with FIND

Posted: 17 Mar 2010 11:58
by mhinegardner
I'm not sure the best way to go about doing this...

Ultimately I want to run a MySQL query and run that into a DOS FIND command...from that point, I want to be able to "do" something with the output. Perhaps with an IF statement.

This is what I had in mind:

SET MYSQLOUTPUT=mysql.exe -uroot -ppassword --execute="use db_name;select field from table;"
%MYSQLOUTPUT% | find "string"

After this point is where I'm stuck...

I'd like to be able do something like "IF this string is found...DO this...or goto another function"

Re: IF statement with FIND

Posted: 17 Mar 2010 13:56
by aGerman
Should be something like this:

Code: Select all

for /f "delims=" %%a in ('mysql.exe -uroot -ppassword --execute^="use db_name^;select field from table^;"') do set "MYSQLOUTPUT=%%a"
echo %MYSQLOUTPUT%|find "string" >nul && (
  rem DO this
) || (
  rem goto another function
)