Set mysql variable with the name {parametro1}

Asked

Viewed 84 times

0

The way to set a variable in mysql is like this:

SET @variavel = valor

In the Documentation says that the variable name may contain other characters, in which case it should be set like this SET @'variavel' = valor.

It is possible to create a mysql variable containing the characters { and } ?

  • Why is my question negative? What is the justification for this? What did I do wrong? Speak so I can correct.

  • 1

    It’s normal, I’ve got a negative on the unexplained answer. But this doesn’t change much, positives are worth 5 in question and 10 in answer, negatives only discount 2. But it’s good for us to rethink where to improve.

1 answer

2


After spending a few seconds doing a test, I got the following answer:

Yes, it is possible


The test:

set @'{banana}' = 10;
select @'{banana}'

The result:

10

See the test done and running online on SQL Fiddle.


Updating:

Just to make sure the documentation is correct :), I tested without the quotes and the result was this:

You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near '{banana} = 10' at line 1
  • I’ll check it out and come back.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.