我需要更新具有某些条件的表,但我不知道如何为Sybase编写正确的语法。基本上只有当country为NULL并且street1,street2或street3>时才会运行更新。 40.
UPDATE myTable
SET status = 'X',
reason = 'Address is too long'
when IsNull(Country,' ') = ' ' and Street1 > 40 OR Street2 > 40
OR Street3 > 40
WHERE CatName = 'BB'
AND userid = 258
AND status = 'A'
答案 0 :(得分:1)
将when
逻辑移到where
子句中,例如:
UPDATE myTable
SET status = 'X',
reason = 'Address is too long'
WHERE CatName = 'BB'
AND userid = 258
AND status = 'A'
AND Country is NULL
AND (char_length(Street1) > 40 OR
char_length(Street2) > 40 OR
char_length(Street3) > 40)