Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 MySQL 数据库中有一个包含所有 id 的数组。在第二个数组中,有我需要插入到同一个表中的 ID。我需要检查我要插入的 Id 是否存在于第一个数组中,然后将其插入数据库。
帮助我找到独特的价值。
如果 id 是 PK,您可以在重复更新时使用插入(这里有一个可能对您有帮助的堆栈问题;不相关,但对于语法)重复键忽略?.
使用array_intersect() 函数找出两个数组是否满足您的条件,然后决定是否可以将数据插入 DB