Update 'ZERO' DATETIME values in MySQL
Trying to update mysql rows that have DATETIME value of 0000-00-00 00:00:00 to a new date.
UPDATE wp_posts SET post_date = FROM_UNIXTIME(UNIX_TIME开发者_C百科STAMP('2011-05-02'))
and post_date_gmt = FROM_UNIXTIME(UNIX_TIMESTAMP('2011-05-02'))
WHERE post_date = 0 LIMIT 100
This updates 0
rows, when there are thousands with 0000-00-00 00:00:00
value.
UPDATE wp_posts SET post_date = FROM_UNIXTIME(UNIX_TIMESTAMP('2011-05-02')),
post_date_gmt = FROM_UNIXTIME(UNIX_TIMESTAMP('2011-05-02'))
WHERE post_date ="0000-00-00 00:00:00"
精彩评论