Posted by Justin Koivisto on 10/26/05 20:27
smorrey@gmail.com wrote:
> Just a note I'ld thought I'ld mention.
> The other logical solution is this.
>
> SELECT deposits - withdrawls as balance FROM(
> (SELECT sum(from_amount ) as withdrawls FROM transactions WHERE
> from_user = '1' UNION
> SELECT sum(to_amount) as deposits FROM transactions WHERE to_user =
> '1' )
>
> Which produces the following error
>
> #1248 - Every derived table must have its own alias
>
> I'm going into a corner to cry now.
at the very end of that statement, simply add " as table1" and you
should be good.
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
Navigation:
[Reply to this message]
|