I'm not sure if I need to write a PHP for-loop to do this, or if it can all be 
done in one SQL statement?

Basically, I want to copy all the barcodes from one table and put them into 
another table, but only if the barcode in the first table > 0, and only if the 
wineid's match from table to table.

Steps individually are something like this:

1)  First, I get all the records from the "wine" table that have barcodes, like 

        SELECT *  FROM `wine` WHERE barcode2 > 0

The fields I need are "barcode2", and "wineid"

2)  Next, I need to match all the wineid's from this "wine" table with the wine 
id's from the "usersdata" table.  Both fields in both tables are called 

3)  Then, if the wineid's match, I need to copy the "barcode2" value from the 
wine table and put it into the field "custombarcode" in the "usersdata" table.

I'm tempted to write a PHP script which does a while-loop through all the 
records returned from the wine table and do the matching with the usersdata 
table, but I wouldn't be surprised if there's some sort of table-join-type 
query that can do all this in one step.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to