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

  • Home
  • SEARCH
  • 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 8266749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:16:21+00:00 2026-06-08T05:16:21+00:00

as the title says, I want to Insert into table 3 (list_mail_usr) all the

  • 0

as the title says, I want to Insert into table 3 (list_mail_usr) all the rows from a column on table 1 (temp_urs) and just the very last row from 1 column in table 2, you can see, all the rows from column 1 have the same ID which is the last row from the list_id column of the list_mail_nom table.

$tmp_usr = "INSERT INTO list_mail_usr (id_usuario,list_id)
SELECT temp_urs.id_usuario
JOIN list_mail_nom.list_id
WHERE MAX(ID) FROM list_mail_nom.list_id
";

This is what I have so far. And it’s not working obviously ;(
Any suggestions?

This one almost works but insert each row from temp_usr 65 times

$tmp_usr = "INSERT INTO list_mail_usr (id_usuario,list_id)
            SELECT temp_usr.id_usuario,list_mail_nom.list_id
            FROM temp_usr,list_mail_nom";
$insert = $asies -> query($tmp_usr) or die (mysqli_error($asies));
  • 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-08T05:16:22+00:00Added an answer on June 8, 2026 at 5:16 am

    You’re not using aggregate functions correctly. To do what you’re trying to do, you’re going to need to GROUP BY and use a HAVING. A much simpler query would be something like :

    INSERT INTO new_table (new_a, new_b)
    SELECT x.col, y.col
    FROM x, y
    WHERE y.id = (SELECT MAX(id) FROM y)
    

    With large tables, MySQL’s difficulties optimizing subqueries would become apparent. If you can find the maximum ID separately & pass it in as a constant, performance will be much better against large tables (moreso large x than large y, since it’s assumed that there’s an index on your ID).

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

Sidebar

Related Questions

I just want what my title says.I have already read all the previous similar
Just as the title says. I want to write a script that behaves differently
As the title says I want to remove the first 4 letters from a
So as the title says i want to prevent user from keep submiting $_POST
Like the title says, I want to have a HTML table that allows its
As the title says, I just want an output if the if is matched,
Just like the title says; I want to use something like Mid( stringName ,
As the title says i want to call a mixed mode assembly from unmanaged
As the title says, I've got a string and I want to split into
As the title says, then I want to access x. from a let instead

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.