大师,
我需要帮助来修复此查询:
我有更新查询。
UPDATE controll_SZHEAD14
LEFT JOIN [outgoing] ON controll_SZHEAD14.sa_code = [outgoing].Account
SET [outgoing].Account = controll_SZHEAD14.sa_code, [outgoing].Buyer = controll_SZHEAD14.sa_buyername, [outgoing].startdate = controll_SZHEAD14.sa_date, [outgoing].Finance = controll_SZHEAD14.sa_tedat, [outgoing].maxdate = controll_SZHEAD14.sa_esdat, [outgoing].[25alap] = controll_SZHEAD14.sa_summary
WHERE (((controll_SZHEAD14.sa_code)>"BA14/01997"));
因此,如果我在上面运行此查询,则刷新我的数据,但仅从BA14 / 01997到现在。所以在这个例子中,这将刷新66行。 (66排受影响)
我有这个简单的选择sql:
SELECT TOP 1 Account FROM [outgoing] ORDER BY Account DESC;
如果我在上面运行,我得到了最后一个帐户,在这个例子中:BA14 / 01997
所以我想采取这两个问题"更新+选择"在一起。
UPDATE controll_SZHEAD14
LEFT JOIN [outgoing] ON controll_SZHEAD14.sa_code = [outgoing].Account
SET [outgoing].Account = controll_SZHEAD14.sa_code, [outgoing].Buyer = controll_SZHEAD14.sa_buyername, [outgoing].startdate = controll_SZHEAD14.sa_date, [outgoing].Finance = controll_SZHEAD14.sa_tedat, [outgoing].maxdate = controll_SZHEAD14.sa_esdat, [outgoing].[25alap] = controll_SZHEAD14.sa_summary
WHERE (((controll_SZHEAD14.sa_code)>"SELECT TOP 1 Account FROM [outgoing] GROUP BY Account DESC;"));
以上qquery无法正常工作。当我运行时,我受到0行的影响,但我希望与第一次更新查询相同。
知道如何解决这个问题吗?
谢谢
答案 0 :(得分:0)
将SELECT语句括在()括号
中UPDATE controll_SZHEAD14
LEFT JOIN [outgoing]
ON controll_SZHEAD14.sa_code = [outgoing].Account
SET [outgoing].Account = controll_SZHEAD14.sa_code,
[outgoing].Buyer = controll_SZHEAD14.sa_buyername,
[outgoing].startdate = controll_SZHEAD14.sa_date,
[outgoing].Finance = controll_SZHEAD14.sa_tedat,
[outgoing].maxdate = controll_SZHEAD14.sa_esdat,
[outgoing].[25alap] = controll_SZHEAD14.sa_summary
WHERE controll_SZHEAD14.sa_code > (
SELECT TOP 1 Account
FROM [outgoing]
ORDER BY Account DESC
);