aqua data studio mysql variable

721 Views Asked by At

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 
2

There are 2 best solutions below

2
MaxPowers On
set @var = 1
go
select @var
go

or this ...

set @var = 1
/
select @var
/
0
Svenn On

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