0

Today I learned how to decalre a variable from textbook and the code they give me is

'DECLARE test_sql INT DEFAULT 10;'

When I run this line I got an error 1064 syntax error. How to fix my code?

Then I run 'SET @test_sql=30;' and it works so are there any differences between these two codes and can I declare a variable with a default value by using a SET sentence?

enter image description here

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
  • 3
    Does this answer your question? [How to declare a variable in MySQL?](https://stackoverflow.com/questions/11754781/how-to-declare-a-variable-in-mysql) – Hermanto Jul 09 '21 at 05:15
  • 1
    The variable may be declared only in solid code block (BEGIN_END in function, stored procedure, etc.). – Akina Jul 09 '21 at 05:15

0 Answers0