这就是我需要更新的地方:
代码执行,但不更新间隔ID。建议?
UPDATE summary S
JOIN hour_interval H
ON S.hourinterval_id = H.hourinterval_id
SET S.hourinterval_id = H.hourinterval_id
WHERE ('$new_time' BETWEEN H.start_hour AND H.end_hour)
AND summary_id = '$summary_id'"
hourinterval_id start_hour end_hour
1 4:00:00 5:59:59
2 6:00:00 7:59:59
3 8:00:00 9:59:59
4 10:00:00 11:59:59
5 12:00:00 13:59:59
6 14:00:00 15:59:59
7 16:00:00 17:59:59
8 18:00:00 19:59:59
答案 0 :(得分:1)
试试这个:
UPDATE summary S
JOIN hour_interval H
ON '$new_time' BETWEEN H.start_hour AND H.end_hour
SET S.hourinterval_id = H.hourinterval_id
WHERE summary_id = '$summary_id'"