This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC" Watch "JDBC" New topic
Author

JDBC

manikandan malathy
Greenhorn

Joined: Sep 17, 2008
Posts: 13
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

Joined: Oct 13, 2005
Posts: 43935
    
  33
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

Joined: Oct 06, 2007
Posts: 338
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

Joined: Sep 17, 2008
Posts: 13
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

Joined: Oct 13, 2005
Posts: 43935
    
  33
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.
 
Have you checked out Aspose?
 
subject: JDBC
 
It's not a secret anymore!