WillyTheFish Posted February 15, 2010 Share Posted February 15, 2010 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 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! Link to comment https://forums.phpfreaks.com/topic/192175-mysql-query-to-copy-data-from-one-table-to-another-where-article_id-matches/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.