Here is another example. I can't post my table structure unfortunatly.
CREATE TABLE t1(
t1_col1 VARCHAR(10) NOT NULL,
t1_col2 VARCHAR(40) NOT NULL,
t1_col3 SMALLINT
);
CREATE TABLE t2(
t2_col1 VARCHAR(40) NOT NULL,
t2_col2 VARCHAR(10) NOT NULL,
t2_col3 VARCHAR(40) NOT NULL,
t2_col4 SMALLINT
);
CREATE TABLE t3(
t3_col1 VARCHAR(40) NOT NULL,
t3_col2 VARCHAR(10) NOT NULL,
);
I want to be able to udate multiple columns with a select, but if the select doesn't match; don't update with NULL. The select is doing multiple joins to other tables to verify an update.
An example update would be:
UPDATE t1 A SET (A.t1_col1,A.t1_col4) = (SELECT B.t2_col2, C.t2_col3 FROM t2 B INNER JOIN t3 C ON C.t3_col1 = B.t2_col2 WHERE A.t1_col3 = B.t2_col4)
My statement the update is setting multiple columns and the select is doing more joins. But the general idea is here. Note: these are also large tables.
thanks