RE: Count records

"Berglas, Anthony" <[email protected]>
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Direct SQL, all in one query, evaluated on the server.  (Could actually
be two queries with little overhead in this case.)

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) )

May need to rework a bit to be efficient on your RDBMS.

Anthony  

> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Guenter Wildmann
> Sent: Friday, March 30, 2007 12:14 AM
> To: [email protected]
> Subject: [SimpleORM] Count records
> 
> Hello!
> 
> What is the best way to count records in a table with SimpleORM?
> 
> Using the aggregate count-function most RDBMS have or another way?
> 
> What is the best way to limit the number of records in a table?
> This should be used to only keep the e.g. 500 latest records in a
table.
> 
> Thank you in advance for answers.
> 
> Ciao, Guenter
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 


 
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.