What is wrong with this MySQL statement: DECLARE @ID INT

DECLARE @ID INT ;

This statement is very good at MS SQL Server, but it gives me

You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to "DECLARE @ID INT" on line 1

Does anyone have an idea of ​​the reason?

+5
source share
3 answers

DECLARE is used in stored procedures / functions.

If you want to set a variable for regular queries only, use SET

+9
source

try assigning a value to a variable without @

DECLARE id INT;
+3
source

Declare .

:

SET @ID =(Select id from mytable)
0

All Articles