[TriLUG] Any SQL gurus willing to help?

Andrew Perrin clists at perrin.socsci.unc.edu
Mon Dec 17 13:43:19 EST 2007


> see if this works:
>
> UPDATE attempts a1 SET final=true
>   WHERE phone_num IN (SELECT DISTINCT phone_num FROM attempts)
>     AND attempt_when=(SELECT max(attemt_when) FROM attempts a2
>                         WHERE a2.phone_num=a1.phone_num)
>
> (not sure this will work since I haven't actually tested it .... :) )

Nice idea, but:

ncsboe=# UPDATE attempts a1 SET final=true
ncsboe-#    WHERE phone_num IN (SELECT DISTINCT phone_num FROM attempts)
ncsboe-#      AND attempt_when=(SELECT max(attemt_when) FROM attempts a2
ncsboe(#                          WHERE a2.phone_num=a1.phone_num)
ncsboe-# ;
ERROR:  syntax error at or near "a1" at character 17
LINE 1: UPDATE attempts a1 SET final=true
                         ^

thanks-
Andy



----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin (at) unc.edu - http://perrin.socsci.unc.edu
Associate Professor of Sociology; Book Review Editor, _Social Forces_
University of North Carolina - CB#3210, Chapel Hill, NC 27599-3210 USA






More information about the TriLUG mailing list