如何检查主表中是否已存在id [英] How to check if there already exists an id in a main table

查看:101
本文介绍了如何检查主表中是否已存在id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道在使用临时表时是否有办法检查主表中的现有id,然后使用另一个id来插入记录。因为它可能导致使用错误主表中的id相同。

有没有办法做到这一点?我正在使用访问权限和临时表工作正常,但我需要检查是否有答案。

Hi,
I was wondering if there's a way to check an existing id in the main table when using temporary table,then use another id for inserting records.Since it may cause error for using the same id in the main table.
Is there a way to do that?I'm using access and works fine with temp table,but i need to check if there's an answer.

推荐答案

是的,有办法检查主表是否包含一些id。



A)使用单个输入值:

Yes, there is a way to check if main table contains some id.

A) using single input value:
PARAMETERS [id] INT;
SELECT ID
FROM MainTable
WHERE ID = [id];





B)使用id的列表



B) using list of id's

SELECT ID
FROM MainTable
WHERE ID IN (1,3,5,7);





C)使用临时表



C) using temporary table

SELECT ID
FROM MainTable
WHERE NOT ID IN (SELECT ID FROM TempTable);







请参阅我过去的答案 [ ^ ]以获取有关MS Access中的paremetrized查询的更多信息。




Please, see my past answers[^] to get more information about paremetrized queries in MS Access.


这篇关于如何检查主表中是否已存在id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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