Hi, I’m working on a java project where I have to retrieve the last customer added id i.e Max(c_id). But in my database c_id is in text (varchar) format, so how do I retrieve the max?
Connection conn;
Statement st;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:rrr");
st=conn.createStatement();
String query[] ={"SELECT Max(cid) FROM client"};
for(String q : query){
ResultSet rs = st.executeQuery(q);
while (rs.next()) {
String name = rs.getString("cid");
Text1.setText(name);
Check with the following:
select * from client order by cid desc limit 1,1;