문제

I have a table MyTable defined as:

CREATE TABLE MyTable (id SERIAL   NOT NULL, description VARCHAR, date TIMESTAMP)

In this table, description was filled with strings such as "TOP_XXXXXXXXXXXXX.tsp" where the 13 character long "XXX" is the value of the timestamp that should be in the date column. The date column, however, was not or incorrectly filled in.

I want to make an SQL statement to fill date column with the correct values, parsed from the description column. I use H2 database.

도움이 되었습니까?

해결책

UPDATE MyTable 
SET [date] = CAST(SUBSTR([description], 4, 13) AS DATETIME)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top