Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在使用变量时,sql update语句语法正确_Sql_Lua_Coronasdk - Fatal编程技术网

在使用变量时,sql update语句语法正确

在使用变量时,sql update语句语法正确,sql,lua,coronasdk,Sql,Lua,Coronasdk,这看起来很基本,但在使用变量时,我找不到正确的语法 这项工作: local updateTable = [[UPDATE userDetails SET month_id = 100 WHERE id=1]] db:exec( updateTable) 以下内容不适用: local myVariable = 100 local updateTable = [[UPDATE userDetails SET month_id = myVariable WHERE id=1]] db:exec

这看起来很基本,但在使用变量时,我找不到正确的语法

这项工作:

local updateTable = [[UPDATE userDetails SET month_id = 100 WHERE id=1]]

db:exec( updateTable)
以下内容不适用:

local myVariable = 100

local updateTable = [[UPDATE userDetails SET month_id = myVariable WHERE id=1]]

db:exec( updateTable)

只需使用concat操作符,
,如下所示:

local updateTable = [[UPDATE userDetails SET month_id = ]] .. myVariable .. [[ WHERE id=1]]

如果
myVariable
来自应用程序外部,请注意SQL注入。请参阅:,或Google for

@user1462136:如果有效,通常会按右边的绿色复选框接受他的答案。