Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

tsql

mysql

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?

like image 912
Ahmed Mozaly Avatar asked Apr 18 '09 16:04

Ahmed Mozaly


2 Answers

DECLARE is used in stored procedures/functions.

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

like image 86
Darryl E. Clarke Avatar answered Nov 14 '22 23:11

Darryl E. Clarke


try naming the variable without the @

DECLARE id INT;
like image 35
Jose Basilio Avatar answered Nov 14 '22 22:11

Jose Basilio