[英]How to change the value of this field in all the records of this MySql table?
我有以下情况。
在MySql数据库中,我有一个posts表。 该表包含以下2个字段: post_modified和post_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.