Jump to content

MySql query to copy data from one table to another where 'Article_ID' matches


WillyTheFish

Recommended Posts

Hello everyone.. new to Php and Mysql, so this is probably nothing special for you guys, but it blows my mind right now cause I'm trying to do this using 1 million different loops :P

 

I have two tables which are located in different databases. Looks pretty much like this:

 

Table: "source_table"

Database: "db1"

IDArticle_noProduct_namePrice

1989898radiator23.50

2234255transformator19.20

3142736horse99.99

 

Table: "target_table"

Database: "db2"

IDHeightArticleWeight

112m78631214kg

217m32154139kg

322m23425523kg

 

 

What  i need to do:

I've got an array containing all column names for 'source_table' that shall be imported into 'target_table'.

Let's say these columns are 'Product_name' and 'Price'.

Now i want the script to fetch the value in Product_name' and 'Price' where the value of 'Article_no' (in source_table) matches the value of 'Article' (in target_table).

For the example above this would mean:

create columns 'Product_name'  in 'target_table' and insert the value 'transformator'  (from 'source_table') into 'target_table' where Article = 234255. Same for the column 'Price'. Ignore records where Article and Article_no don't match.

 

Please help! :) thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.