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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:22:04+00:00 2026-05-26T21:22:04+00:00

I ran into a peculiar problem today when I wanted to migrate the history

  • 0

I ran into a peculiar problem today when I wanted to migrate the history data for a table.

I have a table which stores the number of downloads of one type content (say wallpapers). This is the old ‘downloads’ table structure –

Content_ID Download_Count
    1           3
    2           5
    3           20
    4           1
    5           7

Now, I realize that this table does not have any information about when the download was made. So, now I am creating a new table with the following structure.

Content_ID Download_Time
    1           0
    1           0
    1           0
    2           0
    2           0
    2           0
    2           0
    2           0
    3           0
    3           0
    3           0  etc

In the new table structure, the number of times a Content_ID appears will say the number of downloads. Now I want to move the existing data to this table. For that, a query is needed. The query should generate the data for the new table from the old table data. For example, if Content_ID has 3 downloads, we need to insert 3 records in to the new table. Similarly, we need to insert 5 records for Content_ID 2 etc. How to generate a output like this in a query?

I use mysql.

  • 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-26T21:22:04+00:00Added an answer on May 26, 2026 at 9:22 pm

    With a table of numbers (from 1 or 0 up to a high enough value) you can do a query like this.

    select d.Content_ID, 0 as Download_Time
    from downloads as d 
      inner join Numbers as N
        on N.number between 1 and d.Download_Count;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ran into a peculiar problem with NSXMLParser. For some reason it cuts
I ran into a problem today. I got a table with coins values :
Ran into an issue today that I have not been able to resolve. I
Ran into a strange problem in PHP today and I'm wondering if someone can
I ran into a strange problem today, after renaming a couple of images in
Ran into a problem. I have a spawned thread that must call its finally
I ran into the following problem and cannot decide how to proceed: I have
Ran into an interesting problem with a MySQL table I was building as a
I ran into an issue today and I have been stumped for some time
Ran into this problem today, posting in case someone else has the same issue.

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.