|
Posted by petersprc on 07/22/07 13:15
Sure,
Some DBs can do:
update table1, table2 set table1.scanned = 1 where table1.id =
table2.id
Not sure if postgresql does that syntax, but I know this would work in
postgresql:
update table1 set scanned = 1 from table2 where table1.id = table2.id
I know in postgresql you can do
On Jul 21, 8:07 pm, newbie <mitbb...@yahoo.com> wrote:
> Say I have two tables
>
> table1
> ---------------------------------------------------------------
> | id | scanned | title |
> ---------------------------------------------------------------
> | 01 | 0 | book |
> ---------------------------------------------------------------
> | 02 | 0 | paper |
> ---------------------------------------------------------------
> | 03 | 1 | paper |
> ---------------------------------------------------------------
>
> table2
> ---------------------------------------------------------------
> | id | owned_by | notes |
> ---------------------------------------------------------------
> | 01 | tom | good |
> ---------------------------------------------------------------
> | 01 | sam | boring |
> ---------------------------------------------------------------
> | 02 | sam | terrific |
> ---------------------------------------------------------------
>
> Can I join the two tables and at the same time update the field
> 'scanned' on the rows
> being selected? i.e., I am looking for something like:
>
> $query = "SELECT table1.title, table1.scanned, table2.owned_by,
> table2_notes ".
> "FROM table1, table2 ". "WHERE table1.id = table2.id";
> // (however, I want to update table1.scanned field of all the entries
> being selected, and hopefully atomic to the above select)
>
> Is it possible?
> Thanks a lot
Navigation:
[Reply to this message]
|