3.6.5 Using User Variables
You can use MySQL user variables to remember results without having to store them in
temporary variables in the client. See Section 10.3 [Variables], page 524.
For example, to find the articles with the highest and lowest price you can do this:
mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
Mysql version 4.1.8-nt ja tuo muuttuja juttu vaan
ei suostu toimimaan.
Tässä sql lause mitä kokeilin
SELECT @min_price:=MIN(hinta) FROM laite
ja tässä virhe ilmoitus
...right syntax to use near '(hinta) FROM laite' at line 1
You can use MySQL user variables to remember results without having to store them in
temporary variables in the client. See Section 10.3 [Variables], page 524.
For example, to find the articles with the highest and lowest price you can do this:
mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
Mysql version 4.1.8-nt ja tuo muuttuja juttu vaan
ei suostu toimimaan.
Tässä sql lause mitä kokeilin
SELECT @min_price:=MIN(hinta) FROM laite
ja tässä virhe ilmoitus
...right syntax to use near '(hinta) FROM laite' at line 1
Vastaukset
Vanhimmat
Ei vielä vastauksia
Aloittaja odottaa vastauksia. Kerro oma näkemyksesi ensimmäisenä.