On Sat, Aug 9, 2008 at 1:32 AM, Niel Archer <not@xxxxxxxxxx> wrote: > Hi > > You do not say how you identify the last call (there is no date/time > field for example), so a complete answer is not really possible With the "id (auto incremented int)", the last record of either table would be the largest id in a particular group. > Do not use "NOT LIKE 'Completed'", it's an inefficient way of doing "!= > 'Completed'" I'll modify that as you said. My real concern is that $theHugeListOfIncidentIds keeps growing and is used in the "Calls.id IN ($theHugeListOfIncidentIds)". Even if the $theHugeListOfIncidentIds was replaced with an actual MySQL query instead of first being processed by PHP, I think that is a bad approach (but maybe that is the solution if I only change this query and do not change/add columns or states). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php