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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:09:58+00:00 2026-06-15T04:09:58+00:00

I’m using PHP/MySQL and I have to create a new table from an existing

  • 0

I’m using PHP/MySQL and I have to create a new table from an existing one. Here’s the problematic:

Table1:

photo_id   email          name_to   creation_date    link
1          foo1@bar.com   paul      2012-11-21       link1.com
2          foo2@bar.com   mark      2012-11-22       link2.com
3          foo1@bar.com   alex      2012-11-23       link3.com
4          foo1@bar.com   saul      2012-11-25       link4.com
5          foo1@bar.com   john      2012-11-26       link5.com
6          foo2@bar.com   math      2012-11-27       link6.com
7          foo3@bar.com   fred      2012-11-28       link7.com

In Table1 the email is not unique, it can be repeated several times. Each link is different. With this data, I have to create a new table in which the email is unique with maximum of 3 links if there’s more entries of one email (if so I need the data of the 3 latest entries).

So, in this case, Table2 would be like:

email           link1        creation_date1    name_to1    link2        creation_date2    name_to2    link3        creation_date3    name_to3
foo1@bar.com    link5.com    2012-11-26        john        link4.com    2012-11-25        saul        link3.com    2012-11-23        alex
foo2@bar.com    link6.com    2012-11-27        math        link2.com    2012-11-22        mark
foo3@bar.com    link7.com    2012-11-28        fred 

I know the GROUP_CONCAT feature but it’s not really what I need here since the links would all be in the same column. Is it better to make a SELECT * FROM table1 and process the result into PHP arrays and after that create Table2 or a unique MySQL query would do the trick? Or create multiple MySQL tables?

Table1 is over 10 millions rows.

Any advice would be appreciate.

Thanks.

  • 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-15T04:09:59+00:00Added an answer on June 15, 2026 at 4:09 am

    1) select all unique emails.

    2) For each email, take the first 3 rows with that email ordered by creation_date descending.

    3) Use that data to insert into new table.

    Whatchu think?

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm trying to create an if statement in PHP that prevents a single post

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.