What's wrong with this MySQL statement: DECLARE @ID INT

10,915

Solution 1

DECLARE is used in stored procedures/functions.

If you're looking to set a variable for just regular queries, use SET

Solution 2

try naming the variable without the @

DECLARE id INT;
Share:
10,915
Ahmed Mozaly
Author by

Ahmed Mozaly

Updated on June 12, 2022

Comments

  • Ahmed Mozaly
    Ahmed Mozaly about 2 years
    DECLARE @ID INT ;
    

    This statement parses fine with MS SQL Server, but gives me

    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 @ID INT' at line 1

    Does anyone have any idea about the reason?