List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:June 19 2007 10:40pm
Subject:Re: How do you reference custom column names
View as plain text  
In the last episode (Jun 19), Scott Haneda said:
> SELECT 1+1 as foo, 2 as bar, foo+bar
> 
> This will not work, but I think you can see what I am trying to do. 
> I need to run a pretty hefty update on a database, and there are some
> pretty heavy calculations I will be doing.  The result of many of
> those, needs to be further used to make updates on other columns.
> 
> Can someone suggest a method to do this so my SQL is not so non-manageable?

User variables?

mysql> SELECT @foo:=1+1 as foo, @bar:=2 as bar, @foo+@bar as foobar;
+-----+-----+--------+
| foo | bar | foobar |
+-----+-----+--------+
|   2 |   2 |      4 | 
+-----+-----+--------+

-- 
	Dan Nelson
	dnelson@stripped
Thread
How do you reference custom column namesScott Haneda19 Jun
  • Re: How do you reference custom column namesDan Nelson19 Jun