Joseph,
> select d.field1, d.field2, u.field1, u.field2, (select ml.field from
> mltable where ml.key1
> = u.key1 and ml.key2 = u.key2 order by ml.serial desc limit 1) from
> utable u, dtable d,
> where u.key1 = d.key order by d.somefield limit 25 offset ???;
>From the look of it, you want to simply take the utable references out
of the subselect. Try:
SELECT d.field1, d.field2, u.field1, u.field2, mll.latest
FROM utable u, dtable d,
(SELECT key1, key2, max(serial) as latest
FROM mltable
GROUP BY key1, key2) mll
WHERE u.key1 = d.key
AND u.key1 = mll.key1 and u.key2 = mll.key2
ORDER BY d.somefield
LIMIT 25 OFFSET $pageno
That should give you the utable and dtable records, plus the last serial
value while executing the subselect only once per query call. Give it a
spin.
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology [EMAIL PROTECTED]
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster