1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Rep Power

    help update a table from values from another table

    Hey guys,

    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?
  2. #2
  3. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Central Florida, USA
    Rep Power
    Read the UPDATE documentation. PostgreSQL allows such a construct as:
    UPDATE table1 SET table1.column=table2.somecolumn
    FROM table1, table2
    WHERE table1.anothercolumn = table2.yetanothercolumn;
    Be aware that this syntax is an extension to ANSI SQL and might not be supported in other database systems.

    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.
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com

IMN logo majestic logo threadwatch logo seochat tools logo