0

How to set values to variable using SET in MySql?

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

4 Comments

But is it correct how i have set to set values using SET ?
@Mayur, yes, see here for details: stackoverflow.com/questions/1009954/…
Ok i am confused that where to use double Quot Single Quot or no Quot ?
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/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.