September 17th, 2003, 05:45 PM
help update a table from values from another table
I need some help here. I have a table customers that has an email column and a planner column + other columns
I also have a table entries that tha has an email column and a planner column
I need to update all customers.planner with values from entries.planner where the emails of both tables match.
I can't copy the table because that data is different for both tables I just need to same data for the planner. Any ideas?
September 18th, 2003, 09:41 AM
Read the UPDATE documentation. PostgreSQL allows such a construct as:
Be aware that this syntax is an extension to ANSI SQL and might not be supported in other database systems.
UPDATE table1 SET table1.column=table2.somecolumn
FROM table1, table2
WHERE table1.anothercolumn = table2.yetanothercolumn;
There are plenty of other ways of accomplishing this sort of thing if you bother to write a stored procedure, trigger, or a RULE on a joined view.