bash 中的 mysql 变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4228840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 22:56:22  来源:igfitidea点击:

mysql in bash with variable

linuxbashshellmysql

提问by Nico Laemers

How can i parse a variable in a mysql update statement in a bash script?

如何在 bash 脚本中解析 mysql 更新语句中的变量?

i have this but its not going to work

我有这个,但它不会工作

mysql -h HOST -u USERNAME -pUGUESIT -D DATABASE -bse "DELETE FROM table WHERE Position='" .  ."'; DELETE FROM table WHERE Instance='" .  . "';" 

ofcourse username and pass etc are correct but not for public. The question is how I can use the $4 in the statement...

当然用户名和通行证等是正确的,但不适用于公众。问题是我如何在语句中使用 $4...

Thanks in advance!

提前致谢!

回答by Ike Walker

You should be able to do it like this:

你应该可以这样做:

"DELETE FROM table WHERE Position=''; DELETE FROM table WHERE Instance='';"