我有一个表tbl\u sc\u 3\u 4\u ps,其结构如下(id\u team的多个条目可以在一分钟内完成!!!):
+--------+---------+--------+----------+------+---------------------+
| id | id_team | bill_n | bill_min | ps | c_minute |
+--------+---------+--------+----------+------+---------------------+
| 175019 | team1 | 0.0489 | NULL | NULL | 2018-08-07 00:00:00 |
| 175020 | team1 | 0.0500 | NULL | NULL | 2018-08-07 00:01:00 |
| 175021 | team1 | 0.0464 | NULL | NULL | 2018-08-07 00:02:00 |
| 175022 | team1 | 0.0392 | NULL | NULL | 2018-08-07 00:03:00 |
| 175023 | team1 | 0.0504 | NULL | NULL | 2018-08-07 00:04:00 |
| 175024 | team1 | 0.0484 | NULL | NULL | 2018-08-07 00:05:00 |
| 175025 | team1 | 0.0475 | NULL | NULL | 2018-08-07 00:06:00 |
| 175026 | team1 | 0.0500 | NULL | NULL | 2018-08-07 00:07:00 |
| 175027 | team1 | 0.0453 | NULL | NULL | 2018-08-07 00:08:00 |
| 175028 | team1 | 0.0445 | NULL | NULL | 2018-08-07 00:09:00 |
+--------+---------+--------+----------+------+---------------------+
并想从tbl\u sc\u 3\u 4\u bill\u min更新bill\u min列(一个c\u min只能有一个bill\u min,c\u min是pkey):
+---------------------+----------+
| c_minute | bill_min |
+---------------------+----------+
| 2018-08-07 00:00:00 | 0.0418 |
| 2018-08-07 00:01:00 | 0.0766 |
| 2018-08-07 00:02:00 | 0.1188 |
| 2018-08-07 00:03:00 | 0.1556 |
| 2018-08-07 00:04:00 | 0.2002 |
| 2018-08-07 00:05:00 | 0.2416 |
| 2018-08-07 00:06:00 | 0.2779 |
| 2018-08-07 00:07:00 | 0.3187 |
| 2018-08-07 00:08:00 | 0.3614 |
| 2018-08-07 00:09:00 | 0.4000 |
+---------------------+----------+
我的sql语句:
update dbsdme.tbl_su_3_4_ps as a
inner join dbsdme.tbl_sc_3_4_bill_min as b on b.c_minute = a.c_minute
set a.bill_min = b.bill_min
where a.bill_min is NULL;
这不仅更新bill\u min列,还更新c\u min列(执行查询时带有时间戳):
+--------+---------+--------+----------+------+---------------------+
| id | id_team | bill_n | bill_min | ps | c_minute |
+--------+---------+--------+----------+------+---------------------+
| 175019 | team1 | 0.0489 | 0.0418 | NULL | 2018-08-12 10:29:31 |
| 175020 | team1 | 0.0500 | 0.0766 | NULL | 2018-08-12 10:29:31 |
| 175021 | team1 | 0.0464 | 0.1188 | NULL | 2018-08-12 10:29:31 |
| 175022 | team1 | 0.0392 | 0.1556 | NULL | 2018-08-12 10:29:31 |
| 175023 | team1 | 0.0504 | 0.2002 | NULL | 2018-08-12 10:29:31 |
| 175024 | team1 | 0.0484 | 0.2416 | NULL | 2018-08-12 10:29:31 |
| 175025 | team1 | 0.0475 | 0.2779 | NULL | 2018-08-12 10:29:31 |
| 175026 | team1 | 0.0500 | 0.3187 | NULL | 2018-08-12 10:29:31 |
| 175027 | team1 | 0.0453 | 0.3614 | NULL | 2018-08-12 10:29:31 |
| 175028 | team1 | 0.0445 | 0.4000 | NULL | 2018-08-12 10:29:31 |
+--------+---------+--------+----------+------+---------------------+
有人知道为什么c\分钟栏也会更新吗?我只想更新一下bill琰min。
致以最诚挚的问候
简
暂无答案!
目前还没有任何答案,快来回答吧!