MySQL的CURRENT_TIMESTAMP函數可以用于在UPDATE語句中更新表中的時間戳字段。以下是使用CURRENT_TIMESTAMP函數進行更新操作的技巧:
UPDATE table_name SET timestamp_field = CURRENT_TIMESTAMP WHERE condition;
UPDATE table_name SET timestamp_field_1 = CURRENT_TIMESTAMP, timestamp_field_2 = CURRENT_TIMESTAMP WHERE condition;
UPDATE table_name SET timestamp_field_1 = CURRENT_TIMESTAMP, timestamp_field_2 = CURRENT_TIMESTAMP, ... WHERE condition;
UPDATE table_name SET timestamp_field = NULL WHERE condition;
UPDATE table_name SET timestamp_field = '2022-01-01 00:00:00' WHERE condition;
請注意,使用CURRENT_TIMESTAMP函數會將當前時間戳更新到字段中,因此可以確保時間戳字段始終包含最新的時間信息。