以子查询作为数据源的SQL更新不´;t工作(Postgresql)
我有以下SQL DML Update命令,但语法不正确,该命令不起作用:以子查询作为数据源的SQL更新不´;t工作(Postgresql),sql,database,postgresql,Sql,Database,Postgresql,我有以下SQL DML Update命令,但语法不正确,该命令不起作用: UPDATE hmsg_vehicle_category SET hmsg_vehicle_category.hmsg_id, hmsg_vehicle_category.vehiclecategories_inputname SELECT l_p.hmsg_id, tmp_p_vc.inputname FROM hmsg_him_product AS l_p INNER JOIN ( SELECT p.id, vc.
UPDATE hmsg_vehicle_category
SET hmsg_vehicle_category.hmsg_id, hmsg_vehicle_category.vehiclecategories_inputname
SELECT l_p.hmsg_id, tmp_p_vc.inputname
FROM hmsg_him_product AS l_p INNER JOIN ( SELECT p.id, vc.inputname
FROM him_product p INNER JOIN vehicle_category vc
ON p.id = vc.product
ORDER BY p.id, vc.inputname DESC ) AS tmp_p_vc
ON l_p.products_id = tmp_p_vc.id
WHERE l_p.hmsg_id = 171;
如何执行此SQL命令?snytax中的错误在哪里
谢谢你的帮助
格里茨
Marwief类似于:
update hmsg_vehicle_category set
hmsg_id = l_p.hmsg_id,
vehiclecategories_inputname = tmp_p_vc.inputname
from hmsg_him_product as l_p
inner join him_product as p on p.id = l_p.products_id
inner join vehicle_category as vc on vc.product = p.id
where l_p.hmsg_id = 171
请注意,此选项将更新hmsg\u车辆类别
表中的所有记录。您可能希望将其添加到where
子句中:
update hmsg_vehicle_category as hvc set
vehiclecategories_inputname = tmp_p_vc.inputname
from hmsg_him_product as l_p
inner join him_product as p on p.id = l_p.products_id
inner join vehicle_category as vc on vc.product = p.id
where
l_p.hmsg_id = 171 and hvc.hmsg_id = 171
但我目前无法提供更具体的建议,因为您的问题不清楚。您想更新什么还不清楚。您没有告诉它要更新的
hmsg\u vehicle\u类别中的哪些行。你说的是更新tableA,其中tableB.id=171
,这可能是数据库中的更新旅程。距离desk.Material='Wood'
,你没有给出2之间任何联系的指示。