In my table I have a column dato that hold a datetime:
在我的表中,我有一個包含datetime的列dato:
2011-04-12 10:37:07
2011-04-12 10:31:07
2011-04-10 10:32:07
2011-04-11 10:45:07
2011-04-12 10:37:07
I want to change all of the dato columns hour to 00:00:00
我想把所有的dato列都改成00:00
How is it done?
它是如何做的?
1
You can do this with the following query
您可以使用以下查詢進行此操作
UPDATE <table> SET <date column>= DATE(<date column>);
E.g.
如。
UPDATE Customer SET startDate = DATE(startDate);
You can do it from the console using the mysql
tool.
您可以使用mysql工具在控制台實現。
0
See Update multiple records simultaneously with ActiveRecord in Rails using one query?
使用一個查詢在Rails中使用ActiveRecord同時更新多個記錄?
0
I believe you want to alter multiple records rather than columns. Anyway:
我相信您希望更改多個記錄,而不是列。無論如何:
UPDATE mytable
SET dato = DATE_FORMAT(dato, '%Y-%m-%d 00:00:00');
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/04/13/725d13fe8e5cf0d66221df68524a987a.html。