I'm used to MSSQL's Query Analyzer. Needing to convert some SP's for a hobby project, I'm having trouble making the transition to the mysql query browser, particularly when it comes to using variables. I'm essentially trying to simulate a procedure before it's a procedure.
So in Query Analyzer i'd write something like this...
delcare @var1 int
declare @var2 varchar(30)
set @var1 = 17 --some thing i'd normally pass to the SP
set @var2 = 'something else id pass to the SP'
SELECT *
FROM table
WHERE id = @var1
OR textcolumn = @var2
Then I'd play around with the query (cause it's way more complex that the example one) until I got it right, or I'd substitute the values for the variables cause they're used like 100 times in the body of the query and that's a lot of retyping.
So my question is how to get that to work in MySQL's query browser.
I understand that it's only executing whatever statement is highlighted (the cursor is on that line or block of text). And I think i understand that the "Begin Transaction" button should be used somehow, but I can't get it to go. Here's what I have so far
DELIMITER $$
begin
declare var1 varchar(1) default 'W';
select count(*) from gamestatspitchers where wls = var1;
end$$
delimiter ;
Thanks for any help. I can't seem to sort this out.