MySQL stored procedure variables

A few months ago we wrote a mammoth we application which had an SQL Express DB. We used stored procedures, and after writing 170 of them(I didn’t write all of them of course), I was quite used to the way that variables and so on worked in SQL Server.

We’ve started a new project where the DB is MySQL 5. Again we are using stored procedures, but variables work differently.

Setting a variable in SQL Server

DECLARE @oldPageGUID uniqueidentifier;
SET @oldPageGUID = (SELECT mPage.id FROM mPage WHERE mPage.title = @passedtitle);

Setting a variable in MySQL Server

DECLARE dateAdded TIMESTAMP;
SELECT lusers.dateadded INTO dateAdded FROM lusers WHERE lusers.id= id;

You can see that setting the value of the variable is done completely differently (MySQL Docs for SELECT … INTO Statement). Two other things that confused me for a while was that there is no character prefixed to the variables in MySQL as in SQL server (@) and that there is no uniqueidentifier data-type for GUIDs