sql server - SQL Update subquery returns no results run different sub query -
i trying update , i'm having problems (using microsoft sql server)
update mytable set myvalue= ( (select myvalue someothertable someothertable.id=mytable.id) ) table mytable mytable.custname='test' basically subquery return no results if happen want call different subquery:
(select myvalue oldtable oldtable.id=mytable.id)
well, run second query first, , then, first query. in way, override values when first query can bring them, , when (original) first query won't bring result, have result of first query.
also, think have typo in second query table name.
update mytable set myvalue= ( select myvalue oldtable oldtable.id=mytable.id ) table mytable mytable.custname='test' , exists (select 1 oldtable oldtable.id=mytable.id) update mytable set myvalue= ( select myvalue someothertable someothertable.id=mytable.id ) table mytable mytable.custname='test' , exists ( select 1 someothertable someothertable.id=mytable.id) edit: need add exists clause, cause if not update null values, think
Comments
Post a Comment