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 8546375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:00:18+00:00 2026-06-11T13:00:18+00:00

Just before, I posted a question about getting a counter for each duplicate values

  • 0

Just before, I posted a question about getting a counter for each duplicate values in column

Now I’ll extend this question such as:

+------+------+------+
| id   | data | num  | 
+------+------+------+
| 1    | a    |      | 
| 2    | a    |      |
| 3    | a    |      |
| 4    | b    |      |
| 5    | b    |      |
| 6    | c    |      |
| 7    | d    |      |
| 8    | a    |      |
| 9    | b    |      | 
+------+------+------+

could be updated into:

+------+------+------+
| id   | data | num  | 
+------+------+------+
| 1    | a    |   a1 | 
| 2    | a    |   a2 |
| 3    | a    |   a3 |
| 4    | b    |   b1 |
| 5    | b    |   b2 |
| 6    | c    |   c1 |
| 7    | d    |   d1 |
| 8    | a    |   a4 |
| 9    | b    |   b3 | 
+------+------+------+

A big bow to bluefeet anyway!

  • 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-06-11T13:00:19+00:00Added an answer on June 11, 2026 at 1:00 pm

    SOLVED:

    UPDATE mytable
    SET num = ( SELECT num FROM 
    (
    select id,
      concat(data, cast(group_row_number as char)) as num
    from
    (
      select id, data,
            @num := if(@data = `data`, @num + 1, 1) as group_row_number,
            @data := `data` as dummy
      from
      (
        select id, data
        from mytable, (SELECT @rn:=0) r
      ) x
      order by data, id
    ) x  order by id
    ) tempSort
    
     WHERE mytable.ID = tempSort.ID );
    

    Thks again @bluefeet!!

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

Sidebar

Related Questions

I posted a question similar to this earlier, however, after thinking about it and
Before I posted this question, I already looked this , but I couldn't get
Edit at bottom with solution I've seen a similar question to this posted before
I've seen this question asked before and tried following the solutions posted. Unfortunately, they
This question has already been posted before, however, the correct answer doesn't seem to
This Question is a continuation to the one I posted before at: Excel -
I posted a question before about a form submitting to asp. I am more
Before i start id like to say ive posted this question as more of
I posted a question about how to get user input such as YES or
I posted this question here before but there were no responses. I may have

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.