我有这张桌子:
mysql> desc mytab;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| value | varchar(50) | YES | | NULL | |
| template | varchar(50) | YES | | NULL | |
| difference | tinyint(1) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
包含此示例数据:
mysql> select * from mytab;
+----+-------+----------------+------------+
| id | value | template | difference |
+----+-------+----------------+------------+
| 1 | 7 | |2|5|7|8|9|12| | NULL |
| 2 | 0 | |5| | NULL |
| 3 | 5 | |2|5|7|8|9|12| | NULL |
+----+-------+----------------+------------+
3 rows in set (0.00 sec)
如果包含“|value|” ,我想将difference
字段设置为 FALSE template
如果不是,则为 TRUE。
所以结果是:
mysql> select * from mytab;
+----+-------+----------------+------------+
| id | value | template | difference |
+----+-------+----------------+------------+
| 1 | 7 | |2|5|7|8|9|12| | 0 |
| 2 | 0 | |5| | 1 |
| 3 | 5 | |2|5|7|8|9|12| | 0 |
+----+-------+----------------+------------+
3 rows in set (0.00 sec)
我找到了这个解决方案:
秒)