非常简单的操作查询集。但是,您需要使用临时表(如表3)临时保存新的星期数据,然后在处理后迁移到表1。下列选项中使用INNER JOIN
查询匹配两个表:
选项1:删除(上表3的记录 - 一定要创建副本的第一次)/附加(空表3)/删除(前表1记录)/ Append(空表1) - 将每个语句保存为单独存储的查询并按顺序运行它们或将它们作为VBA字符串SQL语句也按顺序编写。
DELETE FROM table3;
INSERT INTO table3 (company, city, product, surcharge)
SELECT t2.company, t2.city, t2.product, t1.surcharge
FROM table2 t2
INNER JOIN table1
ON t1.company = t2.company
AND t1.city = t2.city
AND t1.product = t2.product
DELETE FROM table1;
INSERT INTO table1 (company, city, product, surcharge)
SELECT company, city, product, surcharge
FROM table3;
选项2:表查询(表3成 - 允许它覆盖前一个)/删除(表1,从以前的记录)/附加(空表1)
SELECT t2.company, t2.city, t2.product, t1.surcharge
INTO table3
FROM table2 t2
INNER JOIN table1
ON t1.company = t2.company
AND t1.city = t2.city
AND t1.product = t2.product
DELETE FROM table1;
INSERT INTO table1 (company, city, product, surcharge)
SELECT company, city, product, surcharge
FROM table3;