Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4341412
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:28:54+00:00 2026-05-21T11:28:54+00:00

I have a table:’Categories’ which has two fields:Category_ID and Category. Data in Category_ID field

  • 0

I have a table:’Categories’ which has two fields:Category_ID and Category. Data in Category_ID field are like ‘c1′,’c2’. If There are 10 rows then from c1 to c10. When I insert new record in this table,how can I set the Category_ID like c11 or c12? If none of the record is deleted then its easy to set it according to number of rows.But User can delete the records. I have tried to retrieve Category_ID from the table, stored it in vector, then set one string variable which stores all category_ids separated by ‘;’ I thought to separate c and related digit from Category_ID so that can use the next digit in insert query.

   Statement st;
   ResultSet rsCatID;

   String query="";
   String querySelect="";//used to get last category_id number,so that next value will be applied in insert query.
   Vector vCatID=new Vector();
   String strCatID="";
   String[] arrCatID;    

Then in try catch block-lines after connection,

       querySelect="select Category_ID from Categories";
       rsCatID=st.executeQuery(querySelect);
       while(rsCatID.next()){
            vCatID.add(rsCatID.getString("Category_ID").toString());
       }
       for(int i=0;i<vCatID.size();i++){
           strCatID+=vCatID.get(i).toString()+";";
       }

       System.out.println("strcatidcount=="+strCatID);

       arrCatID=strCatID.split(";");
       for(int i=0;i<arrCatID.length;i++){
            System.out.println("arrCatID=="+arrCatID[i]);
       }  

Now want to split digit from array and want to insert next value and attached it with the character ‘c’ and insert the whole new record. How can I split it? eg. if category_id is c3 then 3 must be stored in another array and for new record 4 ,(c4) will be inserted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:28:55+00:00Added an answer on May 21, 2026 at 11:28 am
    SELECT MAX((CAST(REPLACE(Category_ID,'C','') AS INT))) from Categories
    

    ALTERNATIVELY:

    SELECT MAX(cint(MID(Category_ID,2))) FROM Categories;
    

    This will bring the highest intnum back

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have table field defined as like this approved_at DATETIME YEAR TO SECOND NOT
I have table with product_category and its has more than 20 categories and I
I have table in which i would like to tap on the cell and
I have table with data about tasks like Id, Name, Date, WorkerId, VehicleId (and
I have table inside a div tab. The table has 40 rows in it
I have table rows of data in html being filled from a CGI application.
I have table named as contacts which has nearly 1.2 million records we use
I have table data like this id id1 name 1 1 test1 1 1
I have table with several fields, one of them is Id auto-increment/primary field. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.