How to set values to variable using SET in MySql?
1 Answer
You don't need to declare the user defined variables, you can just SET them as you have in your question.
Once variable is set you can refer to it in SELECT or other statements, for example:
SELECT @_achat_loc;
+-------------+
| @_achat_loc |
+-------------+
| achat |
+-------------+
1 row in set (0.00 sec)
or
UPDATE a SET b=@_achat_loc;
4 Comments
Mayur Patel
But is it correct how i have set to set values using SET ?
vhu
@Mayur, yes, see here for details: stackoverflow.com/questions/1009954/…
Mayur Patel
Ok i am confused that where to use double Quot Single Quot or no Quot ?
vhu
You need to use single quotes if ANSI_QUOTES has been enabled. See here for more information regarding the quotes: dev.mysql.com/doc/refman/5.1/en/string-literals.html and stackoverflow.com/questions/11321491/…