我必须更新表 test_test 列"testconsent_id"
与表的 id 值test_groupedconsent,
哪里的patient_id
in test_test
and patient_id
in test_groupedconsent
表匹配和
两个表中的creation_date 也匹配。
我正在使用下面的查询,但出现错误 -"near "as": syntax error".
查询出了什么问题?
Update test_test as Tinner join (select id,patient_id,creation_date from test_groupedconsent) as Aon A.patient_id = T.patient_id and A.creation_date = T.creation_dateset T.testconsent_id = A.id;
您不能直接在 UPDATE 语句中使用联接。
您必须使用相关子查询来查找所需的值(在子查询中,您可以做任何您想做的事情,但在这种情况下,您甚至不需要联接):
UPDATE test_test
SET testconsent_id = (SELECT id
FROM test_groupedconsent
WHERE patient_id = test_test.patient_id
AND creation_date = test_test.creation_date);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)