MySQL : When stored procedure parameter name is the same as table column name -


let's have stored procedure setcustomername has input parameter name, , have table customers column name. inside stored procedure want set customer's name. if write

update customers set name = name;

this incorrect , see 2 other ways:

update customers set name = `name`; update customers set customers.name = name;

first 1 works, didn't find in documentation can wrap parameters inside ` characters. or did miss in documentation (link appreciated in case).

what other ways there , standard way such case? renaming input parameter not me (because have automatic object-relational mapping if know mean).

update:

so, there link backticks (http://dev.mysql.com/doc/refman/5.0/en/identifiers.html) it's not explained deep enough how use them (how use them parameters , column names).

and there strange thing (at least me): can use backticks either way:

update customers set name = `name`; //or update customers set `name` = name; //or update customers set `name` = `name`;

and work absolutely same way.

don't think strange? strange behavior explained somewhere?

simplest way distinguished between parameter , column (if both name same) add table name in column name.

update customers set customers.name = name; 

even can add database prefix like

update yourdb.customers set yourdb.customers.name = name; 

by adding database name can perform action on more 1 database single store procedure.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -