File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
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: 36598
    
  16
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: 36598
    
  16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC
 
Similar Threads
question about JTable
sql script works in mssql but not in mysql
can't run query from java war
Multiple updates
Hibernate criterion query with foreign key relation-ship