簡體   English   中英

如何在此MySql表的所有記錄中更改此字段的值?

[英]How to change the value of this field in all the records of this MySql table?

我有以下情況。

MySql數據庫中,我有一個posts表。 該表包含以下2個字段: post_modifiedpost_date

對於帖子表中存在的每條記錄,我需要將post_modified字段的值設置為post_date

我該如何查詢所有表記錄呢?

特納克斯

這很簡單:

UPDATE posts SET post_modified = post_date;

此查詢應完成以下工作:

UPDATE posts SET post_modified=post_date;

您將使用無條件的update來更新所有記錄:

update posts set post_modified = post_date

根據數據庫中的設置,可能不允許無條件的更新。 然后,您將添加一個虛擬條件,以告知數據庫您實際上要更改每條記錄:

update posts set post_modified = post_date where 1 = 1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM