How to declare variable?

[expired user #4412]'s profile image [expired user #4412] posted 14 years ago in General Permalink
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's profile image ansgar posted 14 years ago Permalink
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's profile image kapitannwel posted 6 years ago Permalink

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.