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;
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.
The solution? It’s a simple one – just click the 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…