I have 2 tables
table1
id kode(boolean)
-----------------
1 false
2 false
3 true
table2
id num
1 499
2 390
3 500
result : table1
id kode(boolean)
------------------
1 True
2 True
3 True
I want update table1 kode=true when table2.num < 500
How can this be done for Postgres
You can perform a update-join like below. Though not sure if it's SQL Server
or Postgres
since as commented SQL Server
don't have boolean
type rather it's bit
field.
UPDATE t1
SET t1.kode = true
FROM table1 t1
JOIN table2 t2
ON t1.id = t2.id
WHERE t2.num < 500;
Here is Postgres syntax:
UPDATE table1 AS t1
SET kode = true
FROM table2 AS t2
WHERE t1.id = t2.id AND t2.num < 500;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments