We all know UPDATE sometimes is limited so in order to make some complex
conditional updating we can only rely on the complexity of WHERE clause.
I would like to update my detail table based on master properties (so to set
some value only if the corresponding master record fits some conditions).
On 26 May 2010, at 9:21am, Max Vlasov wrote:
UPDATE detail_table SET somefield=somevalue
WHERE
(SELECT masterfieldtocheck FROM master_table WHERE master_table.id
=detail_table.masterid)=okvalue
Is there a way to alias the master table when I need to check several fields
of the master
Max Vlasov wrote:
We all know UPDATE sometimes is limited so in order to make some complex
conditional updating we can only rely on the complexity of WHERE clause.
I would like to update my detail table based on master properties (so to set
some value only if the corresponding master record
where exists (
select 1 from master_table where
master_table.id=detail_table.masterid and
masterfieldtocheck = okvalue and
masterfield2tocheck = okvalue2);
-- or
where detail_table.masterid in (
select id from master_table where
masterfieldtocheck = okvalue and