为相同id扩展Mysql表
我的表格结构是:为相同id扩展Mysql表,mysql,Mysql,我的表格结构是: id |类型|属性|客户| id |值 1 | 2 | 1 | 1 |一些 2 | 2 | 2 | 1 |此 3 | 2 | 3 | 1 | 4 | 2 | 1 | 2 |酷 5 | 2 | 2 | 2 |刚刚 等 我想为每个客户id添加值='mine'作为属性4 INSERT INTO mytable SET type='2', attribute='4, value='mine' 问题是如何将其绑定到客户id上,并且每个客户只绑定一次?谢谢您的提示回答。谢谢您的提示回答
id |类型|属性|客户| id |值
1 | 2 | 1 | 1 |一些
2 | 2 | 2 | 1 |此
3 | 2 | 3 | 1 |
4 | 2 | 1 | 2 |酷
5 | 2 | 2 | 2 |刚刚
等
我想为每个客户id添加值='mine'作为属性4
INSERT INTO mytable
SET type='2', attribute='4, value='mine'
问题是如何将其绑定到客户id上,并且每个客户只绑定一次?谢谢您的提示回答。谢谢您的提示回答。
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