[sqlite] Update detail record based on master properties

2010-05-26 Thread Max Vlasov
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).

Re: [sqlite] Update detail record based on master properties

2010-05-26 Thread Simon Slavin
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

Re: [sqlite] Update detail record based on master properties

2010-05-26 Thread Igor Tandetnik
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

Re: [sqlite] Update detail record based on master properties

2010-05-26 Thread Max Vlasov
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