> What RDBM are you using? Wouldn't this do it? > > -- MySQL > SELECT * > FROM table > WHERE data1 = '5' > ORDER BY DESC > LIMIT 1
Unfortunately not. If you view the larger query you will get a better idea, and to explain the process... The query returns about 7500 records. AddedToFile is a flag that is set by this template from 0 (as shown in the query) to 1 (to indicate success). While this template is running other things may reset this flag to 0 to indicate a change to data, then once the program has finished it loops back to the top and performs this query again, this time it should only receive about 20-30 results (just the ones re-set). If the "AddedToFile = 0" was moved from the HAVING section to the WHERE section it would change the rows that were returned. IE: if the data was such that the highest stockid had an addedtofile value of 1, using HAVING means it is left out of the result set, moving it toe the WHERE section would include the one below it instead which is not the desired result. Any other ideas? BTW: It is MySQL 4.1.11-nt -- Jay ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211543 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54