Re: [PHP] Copying specific fields from table to table
On 25/02/2008, Rob Gould <[EMAIL PROTECTED]> wrote: > I've got 2 tables. One table which contains a series of barcodes assigned to > product id #'s, and another table with JUST product id #'s. > > I need to somehow transfer all the barcodes from the first table into the > second table, but only where the id #'s match. MySQL? This will update every row in table 2 to have the barcode from table 1. UPDATE table2 INNER JOIN table1 USING (id) SET table2.barcode = table1.barcode; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Copying specific fields from table to table
On Feb 25, 2008, at 5:37 AM, Rob Gould wrote: I've got 2 tables. One table which contains a series of barcodes assigned to product id #'s, and another table with JUST product id #'s. I need to somehow transfer all the barcodes from the first table into the second table, but only where the id #'s match. Can anyone tell me if this is something that can be done with just a SQL statement, or do I need to write a PHP script to loop through the records of both tables and do the copying/mapping? Insert into T2 (bcode) select T1.bcode where T2.id = T1.id; Bojan Tesanovic http://www.classicio.com/ http://www.carster.us/
Re: [PHP] Copying specific fields from table to table
Rob Gould wrote: I've got 2 tables. One table which contains a series of barcodes assigned to product id #'s, and another table with JUST product id #'s. I need to somehow transfer all the barcodes from the first table into the second table, but only where the id #'s match. Can anyone tell me if this is something that can be done with just a SQL statement, or do I need to write a PHP script to loop through the records of both tables and do the copying/mapping? insert into table (field1, field2) select field1, field2 from t1 inner join t2 using (field_id); or something like that. http://dev.mysql.com/doc/refman/5.0/en/insert-select.html -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Copying specific fields from table to table
I've got 2 tables. One table which contains a series of barcodes assigned to product id #'s, and another table with JUST product id #'s. I need to somehow transfer all the barcodes from the first table into the second table, but only where the id #'s match. Can anyone tell me if this is something that can be done with just a SQL statement, or do I need to write a PHP script to loop through the records of both tables and do the copying/mapping? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php