Return to Snippet

Revision: 5238
at February 21, 2008 11:56 by wolfie


Initial Code
To just set to a predetermined value (true, false, 1, 'foo', etc.)

update tblDestination
set tblDestination.col=value
where exists (
select col2.value
from tblSource
where tblSource.join_col=tblDestination.join_col
and tblSource.constraint=value
)

More advanced (sets value to value in secondary select statement):

update tblDestination
set tblDestination.col=(select col2.value from tblSource where tblSource.join_col=tblDestination.join_col and tblSource.constraint=value)
where exists (
select col2.value
from tblSource
where tblSource.join_col=tblDestination.join_col
and tblSource.constraint=value
)

Initial URL


Initial Description


Initial Title
Update from select

Initial Tags
sql, update

Initial Language
SQL