Created
June 24, 2013 17:00
-
-
Save andrezrv/5851634 to your computer and use it in GitHub Desktop.
How to use MySQL variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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