1

How can I use variables in aqua data studio when connecting to a MySQL database? Here is a simple example:

set @var = 1
select @var

or

set @var = 1;
select @var;

This results in the following 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 'select @var' at line 2 
MaxPowers
  • 474
  • 1
  • 4
  • 18

2 Answers2

1
set @var = 1
go
select @var
go

or this ...

set @var = 1
/
select @var
/
MaxPowers
  • 474
  • 1
  • 4
  • 18
  • May I request you to please add some more context around your answer. Code-only answers are difficult to understand. It will help the asker and future readers both if you can add more information in your post. – RBT May 02 '17 at 00:53
  • 1
    Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* it addresses the question. Without that, your answer has much less educational value - remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight May 02 '17 at 08:52
0

Ordinary query editors execute multiple SQL statements and knows how to parse them. Aqua studio with MySQL won't parse different sql statements on it's own. "Aqua Data Studio" using MySQL needs a 'delimiter' to issue > 1, sql statements. (ps declare @var doesn't work in query analyser either) Therefore, the original answer above, and the code below should work but, IN the Context of Aqua Studio connecting to MySQL db. try it literally as is:

GO

Set @myVar = 'Some VAlues'

/

Select @myVar

/

-- no declare

Svenn
  • 1
  • 1