[sqlite] how to do this case when?
How do I alter this SQL, so that the original field remains the same when there is no match? A case when else end should do it, but I can't get it right. UPDATE Table1 SET Field1 = (SELECT Field2 FROM Table2 WHERE Table1.Field1 = Table2.Field1) Thanks for any advice. RBS - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] how to do this case when?
At the end (outside the subquery), add: WHERE Field1 IN (SELECT Field1 FROM Table2) - Jeff -Original Message- From: RB Smissaert [mailto:[EMAIL PROTECTED] Sent: Thursday, January 31, 2008 3:15 PM To: sqlite-users@sqlite.org Subject: [sqlite] how to do this case when? How do I alter this SQL, so that the original field remains the same when there is no match? A case when else end should do it, but I can't get it right. UPDATE Table1 SET Field1 = (SELECT Field2 FROM Table2 WHERE Table1.Field1 = Table2.Field1) Thanks for any advice. RBS - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] how to do this case when?
Found this now: UPDATE Table1 SET Field1 = (case when Field1 IN (SELECT Field1 FROM Table2) then (SELECT Field2 FROM Table2 WHERE Table1.Field1 = Table2.Field1) else Table1.Field1 end) Have a feeling though that this can be shorter. RBS -Original Message- From: RB Smissaert [mailto:[EMAIL PROTECTED] Sent: 31 January 2008 20:15 To: sqlite-users@sqlite.org Subject: [sqlite] how to do this case when? How do I alter this SQL, so that the original field remains the same when there is no match? A case when else end should do it, but I can't get it right. UPDATE Table1 SET Field1 = (SELECT Field2 FROM Table2 WHERE Table1.Field1 = Table2.Field1) Thanks for any advice. RBS - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -