如果表匹配,则将值附加到多值字段中 [英] Append value into multi-valued field if table match

查看:34
本文介绍了如果表匹配,则将值附加到多值字段中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子.一个主表和一个源表.在主表中,我有一个名为已完成"的多值字段,其中包含 [Applied, Pledged, Transcripts].我想要发生的是,如果 master 和 source 中的记录匹配,则将Pledged"附加到多值字段中.到目前为止,这是我的代码:

I have two tables. A master table, and a source table. Inside the master table I have a multi-value field named 'completed' with [Applied, Pledged, Transcripts]. What I want to happen is for 'Pledged' to be appended into the multi-value field if the records match in master and source. So far this is my code:

INSERT INTO Contacts ( Completed.[Value] )
VALUES ('Pledged')
FROM Source
WHERE Contacts.Email = Source.Email;

当我在 Access 上运行查询时,它告诉我SQL 语句末尾缺少分号 (;).我不确定我应该调整什么.感谢所有帮助!

When I run the query on Access it tells me "Missing semicolon(;) at end of SQL statement. I'm not sure what I should tweak. All help is appreciated!

推荐答案

考虑使用 INNER JOIN 而不是 WHERE,使用 SELECT 子句而不是 VALUES.

Consider INNER JOIN instead of WHERE with a SELECT clause instead of VALUES.

INSERT INTO Contacts (Completed.[Value])
SELECT 'Pledged' AS Data
FROM Source INNER JOIN Contacts ON Source.Email = Contacts.Email;

这篇关于如果表匹配,则将值附加到多值字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆