I have two tables:
table1
has columns name a,b
and c
.
table2
has columns name d
and e
.
I need to set table1.a
with the value of table1.b
only if table1.c=table2.d
and table2.e='true'
(it's a bool).
I wrote the following:
UPDATE table1 SET a=(
SELECT t1.b
FROM table1 t1
INNER JOIN table2 t2
ON t1.c = t2.d
WHERE t2.e = 'true');
and got of course:
ERROR: more than one row returned by a subquery used as an expression
********** Error **********
ERROR: more than one row returned by a subquery used as an expression SQL state: 21000
How do I change this to work?