Categories MySQL Using Variables in MySQL Post author By Editor Post date September 24, 2011 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;SET @username := 'jonesr'; SELECT id,fname,lname FROM staff WHERE username = @username; ← Subversion Notes → Trim leading whitespace from a field in MySQL