Set a return value as variable in window batch

僤鯓⒐⒋嵵緔 提交于 2021-01-29 08:14:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!