1---2title: 'Mysql local variables'3date: '2007-05-10'4published_at: '2007-05-10T09:50:00.000+10:00'5tags: ['code', 'mysql', 'programming']6author: 'Gavin Jackson'7excerpt: 'Just learned how to use variables in mysql - the variables are bound to the specific client session - and are destroyed on disconnect. SET @varname = value SELECT max(value) from table into @varname S...'8updated_at: '2007-05-10T10:11:31.076+10:00'9legacy_url: 'http://www.gavinj.net/2007/05/mysql-local-variables.html'10---1112Just learned how to use variables in mysql - the variables are bound to the specific client session - and are destroyed on disconnect.1314```15SET @varname = value1617SELECT max(value) from table into @varname1819SELECT @varname20```2122More documentation is available at [http://dev.mysql.com/doc/refman/5.0/en/user-variables.html](http://dev.mysql.com/doc/refman/5.0/en/user-variables.html)232425