我试图将下面的 INSERT INTO 转换为 UPDATE SET 但我遇到了一些麻烦......我正在使用 SQL Server 2008
INSERT INTO tableA
(c_id, status)
SELECT tableB.c_id, COUNT(*)
FROM tableB
LEFT JOIN tableC
ON tableB.c_id = tableC.c_id
WHERE tableC.c_id != tableC.c_id_update
GROUP BY tableB.bl_id
到目前为止我想出了什么......但是我在关键字'SET'之后的变量c_id和项目的分配方面遇到了麻烦。
UPDATE tableA SET
c_id = tableB.c_id
,items -- count(*)??
SELECT tableB.c_id, COUNT(*)
FROM tableB
LEFT JOIN tableC
ON tableB.c_id = tableC.c_id
WHERE tableC.c_id != tableC.c_id_update
GROUP BY tableB.bl_id