错误-我在此sql查询中做错了什么?

时间:2019-06-11 08:15:03

标签: python sql

我正在尝试使用特定条件从同一张表中更新表中的值,但该表未运行

我已经尝试过使用“ WITH”

update my_table as res1
set res1.my_column = (select res2.my_column from my_table as res2
                      where res2.parent_id is null and res2.is_company = true)
where res1.parent_id=res2.id;

2 个答案:

答案 0 :(得分:0)

只需尝试以下SQL:

update my_table as res1 set my_column = res2.my_column from my_table res2 where res1.parent_id = res2.id and res2.partner_id is null and res2.is_company;

答案 1 :(得分:0)

您没有指定SQL Server的类型,但是通常SELECT的UPDATE需要特定的语法:

How do I UPDATE from a SELECT in SQL Server?