質問

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