Forum Moderators: coopster
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