MySQL Query Browser variable assignment problem solved!

If anyone out there is wondering why they’re getting NULL results when trying to set a variable using MySQL Query Browser, I think I’ve found the answer.
 
Let’s take the example statements below:

set @tmp=5;
select @tmp;

 
Query and result in query browser screenshot.
 
If you run them in the query browser, the second one (select @tmp;) will execute but will give you NULL as a result – whereas if you run that in the MySQL command prompt, you’ll get "5" returned as expected.
 
Query and result in MySQL command line screenshot.
 
The solution?  It’s a simple one – just click the start transaction button:
Start transaction button.
 
According to this post in the MySQL forum, it sounds like this is due to query browser closing the old connection and creating a new connection for each statement, thus erasing any variables set…
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: