问题
How can I use if else statement to echo if value more than 1?
@echo off
setlocal
set "sql=c:\xampp\mysql\bin\mysql.exe"
for /f "usebackq" %%a in (`%sql% -u root -ss -e "select COUNT(*) FROM mytable" mydatabase`) do set TESTVAR=%%a
if %TESTVAR% GEQ 1 (echo Database has already existed.) else echo import
pause
回答1:
Kind of like this:
@echo off
setlocal
set "sql=c:\xampp\mysql\bin\mysql.exe"
for /f "usebackq" %%a in (`%sql% -u root -ss -e "select COUNT^(*^) FROM browser" form_generator`) do set TESTVAR=%%a
if %TESTVAR% LSS 1 echo whatever
pause
来源:https://stackoverflow.com/questions/22817571/set-a-return-value-as-variable-in-window-batch