MySql How to set a local variable in an update statement (Syntax?)

后端 未结 5 1620
[愿得一人]
[愿得一人] 2020-12-24 13:29

How can I set a variable while doing an Update statement? I can\'t seem to figure out the syntax.

So I want something like this below but it\'s saying the syntax is

5条回答
  •  清歌不尽
    2020-12-24 14:01

    I have used php or coldfusion to do something like this, (php example)

    function something($param){
    
       $localVarCleaned = mysql_real_escape_string($param);
    
       mysql_query("
       UPDATE tablename
       SET col = ".$localVarCleaned."
       ");
    }
    

提交回复
热议问题