Re: Update from join
От | Gary Stainburn |
---|---|
Тема | Re: Update from join |
Дата | |
Msg-id | 200607071239.31808.gary.stainburn@ringways.co.uk обсуждение исходный текст |
Ответ на | Update from join (Gary Stainburn <gary.stainburn@ringways.co.uk>) |
Список | pgsql-sql |
On Friday 07 July 2006 11:29, Gary Stainburn wrote: > I know this is probably a FAQ but Google etc hasn't helped. > > I have two tables, both with stock number and registration number in. > The second table always has the correct stock number, the first doesn't. > > I want to copy the data across where the stock number is missing. The > select with join shows the rows requiring update, but I can't think how to > do the update. > I came up with: goole=# update test1 set ud_stock=(select s_stock_no from test2 where test1.ud_registration = test2.s_regno) where ud_stock ~ '^[NU][LD]$'; UPDATE 679 but as you can see, it updated a hell of a lot more than 21 rows. Can anyone improve on this? Gary -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
В списке pgsql-sql по дате отправления: