IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Sorry, I should have put in the aliasing for you:
UPDATE self as child, self as parent
SET child.afield = parent.afield
WHERE (child.ParentID = parent.SelfID)

...if that doesn't work, try a subquery?

UPDATE self as child
SET child.afield = (SELECT parent.afield FROM self as parent WHERE parent.SelfID = child.ParentID)
New The subquery will work
but I'm still trying to play around with the self join format ideas you gave me.

thanks.
New futzing around some more
I can't Sybase to accept the alias in the UPDATE clause, either as a standalone (like MS) or the TableName AlisName form.

I usually don't like the ANSI join syntax, as it always seems more cumbersome - especially when joining multiple tables (not to mention I've never figured out a decent way to do the indentation). In this case, though, the ANSI syntax should clarify which self is being updated:
UPDATE atable\nSET afield = parent.afield\nFROM \n   atable child\n   INNER JOIN atable parent\n      ON child.ParentID = parent.SelfID
     T-SQL to T-SQL Conversion - (ChrisR) - (13)
         Guesses on #1 - (FuManChu) - (3)
             Sorry, I should have put in the aliasing for you: - (FuManChu) - (2)
                 The subquery will work - (ChrisR) - (1)
                     futzing around some more - (ChrisR)
         OT and completely beyond the scope - (drewk) - (7)
             Scott's the one that pointed me in the Sybase direction - (ChrisR) - (6)
                 Cool, and a question - (drewk) - (1)
                     Spelling impaired - (ChrisR)
                 Parent/child IDs - (admin) - (3)
                     When would that be? - (drewk) - (2)
                         That's a big one. - (admin) - (1)
                             OK, but why not ... - (drewk)
         Answer on the Sybase equivalent of REPLACE - (ChrisR)

Specifically, why is he still allowed to make them?
133 ms