我有2个表xcart_products,其中有productid , meta_description
和许多其他字段。所述第二表是已经(productid fieldid and value
)来自不同表的SQL更新表值
我需要的fieldID = 1
的xcart_extra_field_values
值复制到
的xcart_products
表所在的Productid
是相同的meta_description
柱xcart_extra_field_values。
UPDATE `xcart_products` SET meta_description = (SELECT value FROM
xcart_extra_field_values WHERE fieldid = 1 AND
xcart_extra_field_values.productid = xcart_products.productid)
WHERE
xcart_extra_field_values.productid = xcart_products.productid ;
上面我写的SQL,但我得到一个错误
#1054 - Unknown column 'xcart_extra_field_values.productid' in 'where clause'
你有使用连接而不是内部选择语句 – Aboodred1