gpt4 book ai didi

mysql - 如何一次插入和更新多个值

转载 作者:行者123 更新时间:2023-11-30 00:39:23 25 4
gpt4 key购买 nike

我有 1 张 table

customer_assignments 具有 customer_idcategory_id 列。

我想按 customer_id=62 一次插入多个类别 _id,例如 1,2,3 ..表格看起来像

customer_id  category_id 

62 1
62 2
62 3

假设如果我将 category_id 更新为 customer_id=62,例如 1,2,表格看起来就像这样

customer_id  category_id 

62 1
62 2

插入和更新都会同时发生......我是 mysql 新手

我需要查询...

最佳答案

使用 2 个查询1.从客户分配中删除 *2.然后现在使用 INSERT 查询插入您想要的内容

关于mysql - 如何一次插入和更新多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21899072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com