Postgresql – Populate columns of table with other table that doesn’t have relationship

postgresqlpostgresql-9.3update

Hello I have 2 tables in PostgreSQL: the 1st one

"Products" 
id
price
factor1
factor2

the columns factor1 and factor2 they both are empty and I want to populate them with the data of another table

"Article" 
id
factor1
factor2

I want to populate the columns where the id of Product is the same as the Article but the tables doesn't have a relationship to each other or FK so how can I accomplish this?

I've tried this:

UPDATE Products
SET factor1 =
  (SELECT factor1
   FROM Article
   WHERE Article.id = Products.id)
WHERE EXISTS
  (SELECT factor1
   FROM Article
   WHERE Article.factor1 = Products.id)

but I get this error:

SQL Error [42P01]: ERROR: relation "Article" does not exist
Position: 213

Best Answer

The more compact way to write this would be:

UPDATE Products
SET factor1 = article.factor1
from Article
WHERE Article.id = Products.id and products.factor1 is null