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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:10:29+00:00 2026-06-13T06:10:29+00:00

I want to insert data from one table into another where one field equals

  • 0

I want to insert data from one table into another where one field equals another in both tables. So far this works. The problem is, I also need to insert additional data into those same rows that is not included on the first table.


//enter rows into database 
foreach($_POST['sku'] as $row=>$sku)
{ 
//this is the data that needs to be added to the table 
$item_sku=$sku;
$image="/$item_sku.jpg";
$small_image="/$item_sku.jpg"; 
$thumbnail="/$item_sku.jpg";

//currently this is what is working to import data from one table to the other
$sql= "INSERT INTO magento_import (sku, description, price) 
       SELECT PR_SKU, PR_Description, PR_UnitPrice
       FROM products 
       WHERE PR_SKU = '$sku'";

//I need something here to add the above variables to the same row where PR_SKU = '$sku'

if (!mysql_query($sql))
{
die('Error: '.mysql_error()); 
}
echo "$row record added";
}

The columns for the missing data on magento_table are called ‘image’, ‘small_image’, and ‘thumbnail’. This is simple a hack to put data from an old product table into a new product table, export as a CSV, and run a profile in Magento. I don’t need to worry about SQL injections. It’s something I’m running off of a local machine. I’m trying to avoid as much manual data entry as possible while switching products over to a new ecommerce system. Thanks for any help you can give.

  • 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-13T06:10:30+00:00Added an answer on June 13, 2026 at 6:10 am

    Selecting literal values should do what you intend:

    $sql= "INSERT INTO magento_import (sku, description, price, image, small_image, thumbnail) 
           SELECT PR_SKU, PR_Description, PR_UnitPrice, \"$image\", \"$small_image\", \"$thumbnail\"
           FROM products 
           WHERE PR_SKU = '$sku'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to insert data from one of my existing table into another
I want to transfer all data from one table into another with the following
I am trying to insert some data from one table into another but I
I want to move data from one database's table to another database's table. I
I need to write a script to insert data selected from one table into
I want to move some data from one table to another. I wrote a
I want to insert data into a table where I don't know the next
I want to insert a record into a MySQL database table from a formulaire.
I need to copy some data from one table to another in Oracle, while
So I am trying to insert multiples rows of data from one table to

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.