Categories
MySQL

Using Variables in MySQL

Finding the correct syntax for using variables in MySQL can be surprisingly difficult.
Once you know it, it's easy. Here's a start:

SET @username := 'jonesr';
SELECT id,fname,lname FROM staff WHERE username = @username;