• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC

 
manikandan malathy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one problem in my program...

In my table contain 50 records... I am using mysql database.

How to getting every 5th record in my table give any sample code....
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use a subject which tells what the post is about.
I think this is more appopriate for another forum, so I shall move you.
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to rank the rows and use modulus to skip rows... something like this:



In Oracle and DB2 you you have can use the built-in functions to do it in a little cleaner way... something like this:
 
manikandan malathy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am executing this query some error will occur....


Error Msg in MySQL:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) from sample b
where b.emp_no <= a.emp_no) as rn from sample a) z where mod ' at line 1
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MySQL error messages are hardly informative. If you want us to help, please quote the entire SQL statement which produces that error. It may be something tiny like a spelling error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic