更新&使用查询将数据添加到表中 [英] update & add data to a table using query

查看:77
本文介绍了更新&使用查询将数据添加到表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个名为的数据库表:" tbl_adviseurs"与字段;

- ID_adv

- NR_adv(主键)

- 细分

- ZIP

- 电话

- 上午

- AD


现在,每隔一段时间我都会得到更新此表的列表包含;

- 更新行(因此必须更新现有记录)

- 新记录

- 删除的记录

这是在excel中提供的。然后,我在名为import_adv的表中导入此数据。


我现在有一个更新查询这适用于更新现有记录。 qyery中的字段;

- 细分

- Zip

- 电话

- AM

- AD


但是,它不会将新记录附加到现有数据库,也不会删除不在import_adv中的记录。表格


如何确保import_adv表中的新记录附加到tbl_adviseurs?

如何确保删除的记录import_adv表也会从tbl_adviseurs中删除?


任何帮助都将不胜感激!

Pierre

Hi,

I have a database table called : "tbl_adviseurs" with the fields;
- ID_adv
- NR_adv (primary key)
- Segment
- ZIP
- TEL
- AM
- AD

Now, every now and again i get an updated list for this table with;
- update rows (so the existing records must be update)
- new record
- deleted records
This is delivered in excel. I then import this data in a table called "import_adv"

I now have a "update Query" that works fine for updating existing records. Fields in the qyery;
- Segment
- Zip
- TEL
- AM
- AD

However it does not append the new records to the existing database and it does not delete records that are not in the "import_adv" table

How can i make sure that new records in the import_adv table are appended tot the tbl_adviseurs ?
How can i make sure that records that are deleted in the import_adv table are also deleted from the tbl_adviseurs ?

Any help would be greatly appreciated!
Pierre

推荐答案

你需要至少两个查询

一个会更新并追加感兴趣的记录。

一个会删除违规记录的人/>

但是,你还没告诉我们你怎么知道哪些记录要... ...
You''ll need at least two queries
One that will update and append the records of interest.
One that will delete the offending records

However, you haven''t told us how you know which records to what to...

听起来像查找不匹配的查询可能是需要找到import_adv中的记录并且不在tbl_adviseurs中以知道要追加哪些记录。反过来会告诉你要删除哪些。
It sounds like a Find Unmatched query might be needed to find the records that are in import_adv and aren''t in tbl_adviseurs to know which ones to append. A reverse would tell you which ones to delete.


Seth,我们不要在这里猜测,让OP告诉我们。
Seth, let us not guess here, let OP tell us.


这篇关于更新&使用查询将数据添加到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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