Subject | Re: [ib-support] Searching for last record |
---|---|
Author | Arno Brinkman |
Post date | 2002-06-18T15:15:58Z |
Hi,
update catalogue
set last_location =
(select x.location from transfers x where x.id =
(select max(cx.id) from transfers cx where cx.catalog_id = id))
Regards,
Arno
> I'm trying to update catalogue.last_location according last record ofjoin...
> transfers:
>
> update catalogue
> set last_location =
> (select location from transfers x where x.catalog_id = catalogue.id
> and x.id =
> (select max(id) from transfers cx where cx.catalog_id = x.catalog_id))
>
> that update hangs. I've discovered that above subselects use natural
> Pure select is too heavy, but it works fine if looks like :Maybe you did mean this :
>
> select x.location from tranfers x join transfers cx on x.catalog_id =
> cx.catalog_id
> group by x.location
> having x.id = max(cx.id)
>
> Is it better way to do such updates ?
update catalogue
set last_location =
(select x.location from transfers x where x.id =
(select max(cx.id) from transfers cx where cx.catalog_id = id))
Regards,
Arno