Skip to content

Instantly share code, notes, and snippets.

@andrezrv
Created June 24, 2013 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrezrv/5851634 to your computer and use it in GitHub Desktop.
Save andrezrv/5851634 to your computer and use it in GitHub Desktop.
How to use MySQL variables
mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+--------+-------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment