In DolphindDB, is it feasible to use the SET...IF statement with UPDATE in SQL queries?

65 Views Asked by At

Does DolphinDB support the following script?

update tmp set exchangecd='XSHG' if exchangecd='SH' set exchangecd='XSHE' if exchangecd='sz'
1

There are 1 best solutions below

0
On BEST ANSWER

DolphinDB does not support the IF statement, but you can use the CASE statement with WHEN...THEN..., as shown in the following script:

UPDATE tmp SET col1 = CASE WHEN col1 = 'SH' THEN 'hello1' WHEN col1 = 'SZ' THEN 'hello2'    ELSE col1END;