I am trying to get the last ID input that I query in MySQL Database.
Note: The itemid is auto increment and of type integer.
In this example, I want to get the last item query, which is itemcode 13.
Here is the screenshot of the table:
try this
rs = st.executeQuery("select last_insert_id() as last_id from table limit 0,1"); lastid = rs.getString("last_id");
You can do this, the nested queries retrieves the maximum itemcode and then filter the main query in order to fetch the row.
select * from table_name where itemcode = (select max(itemcode) from table_name);
I think, you are trying to retrieve the maximum value of itemcode. Use MAX operator. result will be 13.
itemcode
MAX
13
select max(itemcode) from table_name.
try this