| Author |
select MAX query
|
hel bel
Greenhorn
Joined: Mar 05, 2003
Posts: 3
|
|
Could somebody pleeeeease tell me whats wrong with the following shopping cart code! I'm using a sybase database to hold order information and I'm trying to get the last order id from the order table using a select(MAX) query. CODE: /**************************************** PreparedStatement Stmt = connection.prepareStatement(query); int order_idd = 0; ResultSet resultset= Stmt.executeQuery("SELECT MAX(order_id) from orders"); while(resultset.next()) { order_idd = resultset.getInt(2); } while(products.hasMoreElements()) { Product product = (Product)products.nextElement(); Stmt = connection.prepareStatement(order_info_query); Stmt.setInt(1, order_idd); Stmt.executeUpdate(); } Any help would be greatly appreciated! Thanks!
|
 |
SJ Adnams
Ranch Hand
Joined: Sep 28, 2001
Posts: 925
|
|
|
looks like you are trying to get hold of the 2nd column but the query will only give you one column?
|
 |
 |
|
|
subject: select MAX query
|
|
|