MySQL Forums
Forum List  »  PHP

Updating one Table from Another ( PHP )
Posted by: Jayson A
Date: June 01, 2010 08:06PM

Hello,

I've spent some time on this and i can't seem to get it, I'm trying to update one table from another via certain conditions. Please see code below.


Everything works but the SET and WHERE command ( The JOS is Table1 and Product_price is Table 2 ) It keeps setting the field as the first character 'p'

SET jos_vm_product.product_publish = product_price_update.product_publish

WHERE jos_vm_product.product_sku = product_price_update.product_sku'

Anything you can do to help is much appreciated.




<?php
include 'config.php';
include 'opendb.php';

// ... do something like insert or select, etc

$sql = 'UPDATE jos_vm_product, product_price_update
SET jos_vm_product.product_publish = product_price_update.product_publish
WHERE jos_vm_product.product_sku = product_price_update.product_sku';

mysql_select_db('example');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";

include 'closedb.php';
?>



Edited 1 time(s). Last edit at 06/02/2010 07:08AM by Jayson A.

Options: ReplyQuote


Subject
Written By
Posted
Updating one Table from Another ( PHP )
June 01, 2010 08:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.