简体   繁体   中英

how to update stored hh:mm value to hh:mm:ss in mysql database, the column datatype is String?

i have stored data in the database with String datatype as 10:56, 10:30:89

like this, now is it possible to convert all the data with hh:mm:ss format ie 10:30:89

Please help me here

If your database is holding on a varchar column data related to time in two different formats hh:mm and hh:mm:ss and you want to unify all the records to have the same format you need to identify the records in hh:mm and add a ':00' to them at the end.

You can do that with a query similar to that one:

UPDATE MYTABLE
SET MYCOLUMN = CONCAT(MYCOLUMN, ':00')
WHERE MYCOLUMN NOT LIKE '%:%:%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM