Forum Moderators: coopster

Message Too Old, No Replies

The @-sign in a MySQL SELECT query

looking for the documentation

         

RonPK

2:14 pm on Aug 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just read these two lines of mysql code:

SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summmary=@A WHERE type=1;

The @A:= seems to create a temporary environment variable. Until now, for such situations I'd use something like

$salaries = mysql_result(mysql_query("SELECT [et cetera]"), 0);
mysql_query("UPDATE table2 SET summary=$salaries [..]");

The benefit of using @A:= , I guess, is that it is faster because it saves PHP some work / memory usage.

Anyway, I tried searching for documentation on the @-thing, but SEs and the MySQL site search ignore the character. Does anyone know where I can read more?

hit me if this is the wrong forum; it seemed the most appropiate

coopster

2:39 pm on Aug 28, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Start with Using User Variables [mysql.com] in the manual.

RonPK

2:46 pm on Aug 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks coopster, that's it.