UPDATE MyTable
SET [date] = CAST(SUBSTR([description], 4, 13) AS DATETIME)
Fill a timestamp column from substring info sql
문제
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.
해결책
제휴하지 않습니다 StackOverflow