i have a MySql table full of measurement data.
The measurement date in the table is stored in 5 separate columns: year, month, day, hour, minute.
What i would like to do is to add an extra column with the complete date, in a DateTime format.
So when i have the values
year, month, day, hour, minute
2013 ,1, 13, 17, 15,
there is a datetime field filled with the value '2013-01-13 17:15:00'
I'll add the column first, and after that i would like to execute a sql statement to fill the datetime field.
Can you help me with this sql statement?
(i don't know if it matters, but the statement should run from phpmyadmin)
尝试这个
UPDATE myTable set completeValue=CONCAT(year,"-",month,"-",day," ",hour,":",minute)
执行此操作的SQL标准方法是:
SELECT COALESCE(field1, '-') || COALESCE(field2, '-') || COALESCE(field3, '-') || COALESCE(field4, ':') || COALESCE(field5, ':') FROM table into table.field6
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.