Re: Count records
Guenter Wildmann <[email protected]>
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
Hello Anthony,
Berglas, Anthony <aberglas <at> rsasecurity.com> writes:
>
> Direct SQL, all in one query, evaluated on the server. (Could actually
> be two queries with little overhead in this case.)
Ok, so it is best to use a direct SQL query, thank you.
> It will be a bit of a query though. Something like
>
> DELETE FROM MYTAB X
> WHERE ID <
> (SELECT ID FROM MYTAB Y
> WHERE (SELECT COUNT(*) FROM MYTAB Z
> WHERE ID < Y.ID)
> < 500) )
As i would like to keep the 500 newest records the query-part will look
like this:
SELECT last_access FROM location_cache main
WHERE (SELECT COUNT(*) FROM location_cache sub
WHERE sub.last_access > main.last_access) > 500;
Ciao, Guenter
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/SimpleORM/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/SimpleORM/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/