Bug #31294 Query Browser Is Unable to Use @Variables
Submitted: 29 Sep 2007 17:50 Modified: 1 Oct 2007 13:18
Reporter: Chris S Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Query Browser Severity:S2 (Serious)
Version:1.2.12 OS:Linux (Fedora 7)
Assigned to: CPU Architecture:Any
Tags: Query Browser declare @Variables

[29 Sep 2007 17:50] Chris S
Description:
I'm unable to run a query with multiple statements using @variables. For instance, a simple query like:

set @somevar = 4;
select * from mytable where mycol = @somevar;

generates the error:

[Error] Script lines: 1-2 --------------------------
 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 * from mytable where mycol = @somevar;' at line 1

I'm able to execute these two statements successfully from the commandline, so I don't understand why Query Browser generates an error for syntax that's perfectly valid.

How to repeat:
Open Query Browser. Execute query similar to:

set @somevar = 4;
select * from mytable where mycol = @somevar;

Note error.
[29 Sep 2007 18:11] Chris S
This problem seems related to this thread in the forums:

http://forums.mysql.com/read.php?108,62426,62426#msg-62426

Specifically, this remark by Mike Lischke:

"It's a design flaw that will be corrected in the next major version of QB. It was thought as a means to make the application more flexible, but it did not entirely consider the way, how the MySQL server works."

This post was over a year ago...
[1 Oct 2007 13:18] MySQL Verification Team
Thank you for the bug report. By design QB creates a new connection for every
query, then the variable isn't more valid for the new queries. That was already
reported several times for this reason I am changing the status as duplicate.