在查詢資料,需要進行條件判斷時,一般我們使用case...when實現,當判斷條件為相等時,除了使用case...when實現,還可以使用decode函式。若要使用like、>、《等其他判斷條件時,就只能使用case...when實現了。
下面就解釋下decode()函式的用法。
decode()使用方法:
decode(條件,值1,翻譯值1,值2,翻譯值2,...值n,翻譯值n,預設值)
decode()含義說明:
if 條件=值1 then
return(翻譯值1)
elsif 條件=值2 then
return(翻譯值2)
......
elsif 條件=值n then
return(翻譯值n)
else
return(預設值)
end if
Oracle 中Decode函式的用法
第一種形式 decode 條件 值1 返回值1 值2 返回值2 值n 返回值n 預設值 實現資料的彙總 源資料 彙總後的資料 使用decod...
Mysql中decode函式的幾種用法
1 使用decode判斷字串是否一樣 decode value if1 then1 if2 then2 if3 then3 else 含義為if 條件 值1 then return value 1 elsif 條件 值2 then return value 2 elsif 條件 值n then r...
htmlspecialchars decode
htmlspecialchars decode htmlspecialchars decode 將特殊的 html 實體轉換回普通字元 ht...