Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2004, 08:40 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ani 1 noe how to retrieve record from select max()

I need help regarding this statement ....
i do an query
select max(ID) as maxID from ID

and now i want to retrieve record ....

i use rs.next method
den i rs.getString(maxID)

but it return null

 
Old October 10th, 2004, 08:55 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure what as MaxID is for, I would only use select MaxID from ID.

 
Old October 14th, 2004, 05:11 PM
Authorized User
 
Join Date: Oct 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If he leaves off the max() function he will get multiple rows back - I think the poster is interested in getting the single largest value of the ID field in the ID table.

I think you need quotes around the column name (though it really should have given you a compile error unless you happen to have a variable named maxID floating around)
rs.getString( "maxID" )

You might also be encountering case sensitivity from the database, it might have converted the title to all caps "MAXID" or all lower "maxid". I've done code for both Oracle and Sybase and they handle case sensitivity differently.





Similar Threads
Thread Thread Starter Forum Replies Last Post
select Max 2 rows for each ID veeruu SQL Language 1 January 31st, 2006 05:08 AM
Select two MAX record per each veeruu SQL Language 2 January 23rd, 2006 12:57 AM
How to select 5th Max in a Table ramk_1978 SQL Language 2 December 30th, 2004 01:41 AM
How to select Max hosefo81 MySQL 0 November 25th, 2003 10:27 PM
how to select Max hosefo81 PHP Databases 0 November 21st, 2003 12:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.