[thelist] sql update statement using a subquery (sql server)

Sarah Adams sarahwbs at gmail.com
Mon May 28 15:13:33 CDT 2007


> does this work correctly?
>
> UPDATE Reservations
>    SET ReservedBy = r2.ReservedBy
>   FROM Reservations r
> inner
>   join Reservations r2
>     on r.ParentReservationID = r2.ReservationID
>  WHERE r.ReservedBy IS NULL

Oh dear god. Even your suggestion, rudy, my favourite SQL guru, did
not work; I got the same error message "The table 'Reservations' is
ambiguous".

I suppose I could create a copy of the table and make it work that
way. I just hate to give in like that. But if all else fails, that's
what I'll do.



More information about the thelist mailing list