表架构:
+----------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+---------------+------+-----+---------+-------+
| name | varchar(10) | YES | MUL | NULL | |
| slno | varchar(20) | YES | | NULL | |
| type | int(2) | YES | | NULL | |
| details | text | YES | | NULL | |
+----------------------+---------------+------+-----+---------+-------+
name,slno和type一起形成一个键。
示例数据:
+---------+------+------+-------------------------------+
| name | slno | type | details |
+---------+------+------+-------------------------------+
| name1 | 11 | 1 | {"data":["feats1","feats2"] } |
| name1 | 11 | 2 | {"data":["feats1","feats2"] } |
| name1 | 12 | 1 | {"data":["feats5","feats6"] } |
| name1 | 12 | 2 | {"data":["feats5","feats6"] } |
| name2 | 11 | 1 | {"data":["feats3","feats4"] } |
| name2 | 11 | 2 | {"data":["feats3","feats4"] } |
| name2 | 12 | 1 | {"data":["feats7","feats8"] } |
| name2 | 12 | 2 | {"data":["feats10"] } |
+---------+------+------+-------------------------------+
所以基本上对于name ='name1'的每个条目,都有一个类似的条目,其中slno但是name ='name2'。
我想要做的是为具有相同slno和类型但名称不同的行设置相同的细节,即上面的示例数据集应如下所示。 name2 行的详细信息应与 name1 行的详细信息匹配(如果它们具有相同的slno和类型)。
+---------+------+------+-------------------------------+
| name | slno | type | details |
+---------+------+------+-------------------------------+
| name1 | 11 | 1 | {"data":["feats1","feats2"] } |
| name1 | 11 | 2 | {"data":["feats1","feats2"] } |
| name1 | 12 | 1 | {"data":["feats5","feats6"] } |
| name1 | 12 | 2 | {"data":["feats5","feats6"] } |
| name2 | 11 | 1 | {"data":["feats1","feats2"] } |
| name2 | 11 | 2 | {"data":["feats1","feats2"] } |
| name2 | 12 | 1 | {"data":["feats5","feats6"] } |
| name2 | 12 | 2 | {"data":["feats5","feats6"] } |
+---------+------+------+-------------------------------+
我试过,但无法提出执行上述结果的命令。有人可以帮忙吗?