Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to query a certain number of data?

 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For example, if I want to query the maximum latest 1000 records. How can I ?
For (Select Max(column) from XXX where..) can only display the max value of certain column
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SQL that you need to do this would depend upon the database that you are connecting to.
On Oracle you could do something like:
SELECT * FROM MYTABLE ORDER BY DATE_CREATED DESC WHERE ROWNUM <= 1000
The order by clause will sort the records so that the most recent ones are retrieved first, the where clause will then limit the no of records returned.
I am not sure of the syntax for other DBs but it will be pretty similar if it is supported at all.
Hope this helps
[ March 28, 2003: Message edited by: Andy Bowes ]
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks andy,
but i am using MySQL,
do anyone know if there's any method can work in mysql?thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic