所以我有这两个表,operators_payments AS op填充了数据,但是op.date_paid将为NULL,直到付款日期到达,当这种情况发生时,payment_process AS pp表用于初始化付款(pp.date_started 是设置为 NOW()),然后为完成付款,op.date_paid设置为pp.date_started。显示的查询用于执行此操作,一切都很好,但是当所有记录都更新时,其中一条记录并且只有一条记录以不同的时间获得op.date_paid ,特别是第二条部分例如(时间设置为除一之外的所有时间:2012-07-05 17:28:14 ,时间设置为一:2012-07-05 17:28:02 )。
我使用 Mysql 5.5,列具有相同的类型(TIMESTAMP)。我需要这个,因为我需要日期与 pp.date_started 中的日期完全相同。
我的问题是,为什么会发生这种情况,我该怎么做才能让这种情况受到重视?
UPDATE operators_payments AS op
JOIN payment_process AS pp
ON op.operator_id = pp.operator_id
AND pp.type = 0
AND pp.status = 1
SET op.date_paid = pp.date_started, pp.status = 2, pp.message=CONCAT(SUBSTRING_INDEX(message, '|', 1), '| was completed successfully!')
WHERE op.operator_id = {$this->operator_id}
AND op.date_paid IS NULL
AND op.date_end <= pp.date_accounted
+---------------+-----------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-----------------------+------+-----+-------------------+----------------+
| payment | int(10) unsigned | NO | PRI | NULL | auto_increment |
| operator_id | int(10) unsigned | NO | MUL | 0 | |
| date_paid | timestamp | YES | MUL | NULL | |
| date_start | timestamp | YES | | NULL | |
| date_end | timestamp | YES | MUL | NULL | |
| amount | decimal(6,4) unsigned | NO | | 0.0000 | |
+---------------+-----------------------+------+-----+-------------------+----------------+
+----------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+-------------------+-----------------------------+
| operator_id | int(11) | NO | PRI | NULL | |
| type | tinyint(4) | NO | PRI | NULL | |
| date_started | timestamp | YES | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| date_accounted | timestamp | YES | | NULL | |
| amount | decimal(6,4) | YES | | NULL | |
| status | tinyint(4) | YES | MUL | 0 | |
| message | varchar(255) | YES | | NULL | |
+----------------+--------------+------+-----+-------------------+-----------------------------+