I assume you have a table structure like this:
CREATE TABLE Table1 (
Col1 INT NOT NULL,
Col2 INT NOT NULL,
Col3 INT NOT NULL,
Col4 INT NOT NULL,
Col5 INT NOT NULL,
Col6 INT NOT NULL,
PRIMARY KEY (Col1, Col2, Col3, Col4)
);
CREATE TABLE Table2 (
Col1 INT NOT NULL,
Col2 INT NOT NULL,
Col3 INT NOT NULL,
Col4 INT NOT NULL,
Col5 INT NOT NULL,
Col6 INT NOT NULL,
PRIMARY KEY (Col1, Col2, Col3, Col4)
);
And that you have sample data like this:
INSERT INTO Table1 (
Col1, Col2, Col3, Col4, Col5, Col6
)
VALUES
(1, 1, 1, 1, 25, 7),
(2, 2, 2, 2, 8, 9),
(3, 3, 3, 3, 25, 12);
INSERT INTO Table2 (
Col1, Col2, Col3, Col4, Col5, Col6
)
VALUES
(1, 1, 1, 1, 26, 8),
(2, 2, 2, 2, 9, 10),
(4, 4, 4, 4, 30, 3);
ANSI Solution
You can solve the problem using ANSI update syntax. The ANSI solution looks like this:
UPDATE Table1
SET
Col5 = (
SELECT Col5
FROM Table2
WHERE
Table1.Col1 = Table2.Col1 AND
Table1.Col2 = Table2.Col2 AND
Table1.Col3 = Table2.Col3 AND
Table1.Col4 = Table2.Col4
),
Col6 = (
SELECT Col6
FROM Table2
WHERE
Table1.Col1 = Table2.Col1 AND
Table1.Col2 = Table2.Col2 AND
Table1.Col3 = Table2.Col3 AND
Table1.Col4 = Table2.Col4
)
WHERE EXISTS (
SELECT *
FROM Table2
WHERE
Table1.Col1 = Table2.Col1 AND
Table1.Col2 = Table2.Col2 AND
Table1.Col3 = Table2.Col3 AND
Table1.Col4 = Table2.Col4
);
In the end, the data in Table1 looks like this:
Col1 Col2 Col3 Col4 Col5 Col6
1 1 1 1 26 8
2 2 2 2 9 10
3 3 3 3 25 12
Rows 1 and 2 have been updated because there are corresponding rows in Table2. Row 3 stays the same because there is no corresponding row in Table2.
See my SQLFiddle for a working example. I used the SQL.js implementation of SQLLite on SQLFiddle.
Frankly, the ANSI update syntax sucks. It sucks so badly that every commercial database engine has its own extended syntax to make complex updates easier.
I don't know if SQLite has its own extended syntax or has adopted that of another database engine.
SQL Server solution
You mentioned you tried the SQL Server solution.
Using SQL Server syntax the solution would look like this:
UPDATE Table1
SET
Col5 = Table2.Col5,
Col6 = Table2.Col6
FROM Table1
INNER JOIN Table2 ON
Table1.Col1 = Table2.Col1 AND
Table1.Col2 = Table2.Col2 AND
Table1.Col3 = Table2.Col3 AND
Table1.Col4 = Table2.Col4;
Unfortunately, SQLite doesn't understand it:
SQLite exception: 1, near "FROM": syntax error
The solution probably only works in SQL Server. The currently accepted answer to the linked question shows the different ways of solving a problem for SQL Server, Oracle, MySQL, and ANSI.