VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: gpessoa on January 28, 2013, 23:26:43 PM

Title: Update sentence (SQL QUERY)
Post by: gpessoa on January 28, 2013, 23:26:43 PM
Hi
I need to copy a product description from one database to another
The common field is the product_sku.
The problem is that I can't put the update command working, because  product_sku is in other table and has to be Joined by virtuemart_product_id, and I´m missing this...

Can any one write for me this update sentence for me, please?

Tables and Fields:
jos_virtuemart_products
virtuemart_product_id    
product_sku

jos_virtuemart_products_pt_pt
virtuemart_product_id
product_name

Thanks in advanced
Title: Re: Update sentence
Post by: gpessoa on January 29, 2013, 12:45:48 PM
This is my sentence, but it gives me this error:
#1066 - Not unique table/alias: ' MyDB_old_virtuemart_products_pt_pt'


UPDATE MyDB_old_virtuemart_products_pt_pt    
INNER JOIN
MyDB_old_virtuemart_products_pt_pt ON MyDB_old_virtuemart_products_pt_pt.virtuemart_product_id = MyDB_old_virtuemart_products.virtuemart_product_id 
INNER JOIN
MyDB_new_virtuemart_products_pt_pt ON MyDB_new_virtuemart_products_pt_pt.virtuemart_product_id = MyDB_new_virtuemart_products.virtuemart_product_id 
LEFT JOIN
MyDB_old_virtuemart_products ON MyDB_old_virtuemart_products.product_sku = MyDB_new_virtuemart_products.product_sku
SET
MyDB_old_virtuemart_products_pt_pt.product_desc = MyDB_new_virtuemart_products_pt_pt.product_desc
WHERE
MyDB_old_virtuemart_products.product_sku = MyDB_new_virtuemart_products.product_sku