如何从一个表中获取名称到另一个表的meta_description
中并将其添加到另一个字符串中?
两个表如下:
1. manufacturer_id (manufacturer_id, name)
2. manufacturer_description (manufacturer_id, meta_description)
设置/更新/替换?: 带有名称的meta_description并将字符串连接到名称,例如。 “产品”
结果示例:
meta_description = "Walmart products"
答案 0 :(得分:2)
使用join更新,我在两个字符串之间添加了一个空格,但是如果您不需要它可以轻松删除。
UPDATE manufacturer_description md
JOIN manufacturer_id mi ON md.manufacturer_id = mi.manufacturer_id
SET md.meta_description = CONCAT(md.meta_description,' ' ,mi.name)
答案 1 :(得分:1)
update manufacturer_description d set d.manufacturer_description = d.manufacturer_description ||
(select i.name from manufacturer_id i where i.manufacturer_id = d.manufacturer_id );
您可以尝试以下操作: