How to declare variable?

male110 posted 9 years ago in General
declare i int ;
/* SQL Error: 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 'declare i int' at line 1 */
ansgar posted 9 years ago
That declare syntax is only valid in stored programs, see the MySQL docs.

To define a variable in a session you have to do it this way:
SET @myvar=1;
SELECT @myvar;
kapitannwel posted 6 months ago

hi @ansgar,

can you help me with this:

SELECT * FROM MyTable WHERE user_name LIKE '%VariableName%';

thank you very much.

Please login to leave a reply, or register at first.