gpt4 book ai didi

mysql - 为同一个id扩展Mysql表

转载 作者:行者123 更新时间:2023-11-29 00:24:19 24 4
gpt4 key购买 nike

我的表结构是:

编号 |类型 |属性 |客户编号 |值

1 | 2 | 1 | 1 |一些
2 | 2 | 2 | 1 |这个
3 | 2 | 3 | 1 |那
4 | 2 | 1 | 2 |很酷
5 | 2 | 2 | 2 |只是

等等

我想为每个 customer_id 添加 value='mine' 作为 attribute 4。

INSERT INTO mytable 
SET type='2', attribute='4, value='mine'

问题是如何将它绑定(bind)到 customer_id 并且每个客户只能绑定(bind)一次?

最佳答案

INSERT INTO myTable(type, attribute, customer_id, value)
SELECT 2 type,
4 attribute,
s.customer_id,
'mine' `value`
FROM (SELECT DISTINCT customer_id FROM myTable) s

关于mysql - 为同一个id扩展Mysql表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19686110/

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