Subject Searching for last record
Author Andrew Guts
Hello all.

Please help me with that:

/* less than 30000 records*/
create table catalogue
(id integer not null primary key,
partnumber varchar(30),
last_location integer

/* about 200000 records */
create table transfers (
id integer not null primary key, /* autoincrement by trigger using
GEN_ID() */
catalog_id integer references catalogue (id),
location integer not null
/* ,... */

I'm trying to update catalogue.last_location according last record of

update catalogue
set last_location =
(select location from transfers x where x.catalog_id =
and =
(select max(id) from transfers cx where cx.catalog_id = x.catalog_id))

that update hangs. I've discovered that above subselects use natural join...
Pure select is too heavy, but it works fine if looks like :

select x.location from tranfers x join transfers cx on x.catalog_id =
group by x.location
having = max(

Is it better way to do such updates ?

Thanks ahead