从我的表中插入/更新布尔值的最佳解决方案是什么。
每周或每月,point
可以更改数量,例如当前数据:
+----+----------+-----------+--------------+-------+--------+
| id | phone_id | tarrif_id | affiliate_id | point | active |
+----+----------+-----------+--------------+-------+--------+
| 2 | 6 | 2 | 3 | 7.3 | 0 |
| 3 | 6 | 2 | 3 | 8.5 | 0 |
| 4 | 6 | 2 | 3 | 12.5 | 0 |
| 5 | 6 | 2 | 3 | 3.5 | 1 |
| 6 | 20 | 2 | 3 | 10.5 | 1 |
+----+----------+-----------+--------------+-------+--------+
我会插入一个新的记录phone_id
,tarrif_id
并affiliate_id
带有一个新的点并禁用其他记录active=0
。
新点更改,例如:
+----+----------+-----------+--------------+-------+--------+
| id | phone_id | tarrif_id | affiliate_id | point | active |
+----+----------+-----------+--------------+-------+--------+
| 2 | 6 | 2 | 3 | 7.3 | 0 |
| 3 | 6 | 2 | 3 | 8.5 | 0 |
| 4 | 6 | 2 | 3 | 12.5 | 0 |
| 5 | 6 | 2 | 3 | 3.5 | 0 |
| 6 | 20 | 2 | 3 | 10.5 | 0 |
| 7 | 6 | 2 | 3 | 20.2 | 1 |
| 8 | 20 | 2 | 3 | 33.7 | 1 |
+----+----------+-----------+--------------+-------+--------+