I have this SELECT query which works perfectly:
SELECT T1.Account, T1.Total, T2.Account, T2.Total
FROM tSummary2 as T1
INNER JOIN
(SELECT tSummary2.Account,
Count(FinalData.ID) AS Total
FROM tSummary2
INNER JOIN FinalData
ON tSummary2.Account = FinalData.Account
GROUP BY tSummary2.Account) as T2
ON T2.Account = T1.Account
I need to make T1.Total = T2.Total. But every attempt to turn this into an update query is failing with "SYNTAX ERROR (missing operator).
Here is what I am trying:
UPDATE T1
SET T1.Total = T2.Total
FROM tSummary2 as T1
INNER JOIN
(SELECT tSummary2.Account,
Count(FinalData.ID) AS Total
FROM tSummary2
INNER JOIN FinalData
ON tSummary2.Account = FinalData.Account
GROUP BY tSummary2.Account) as T2
ON T2.Account = T1.Account
What am I missing?
You are missing a SELECT
clause it seems.
UPDATE T1
SET T1.Total = (SELECT T2.Total
FROM tSummary2 as T1
INNER JOIN
(SELECT tSummary2.Account,
Count(FinalData.ID) AS Total
FROM tSummary2
INNER JOIN FinalData
ON tSummary2.Account = FinalData.Account
GROUP BY tSummary2.Account) as T2
ON T2.Account = T1.Account)
I just added the SELECT before T2.Total
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.