close

用途:問卷調查之類...

常常在資料庫內顯示的欄位為1.2.3等...
若要給人查閱的時候,為了方便閱讀,將會使用select case的方式。

語法:
case 欄位名稱 when '內容' then '轉換內容' else 欄位 end

舉例:
問卷調查如下
你喜歡這個網站嗎?1.喜歡        2.不喜歡        3.還可以        4.原因

資料庫內欄位有1有2有文字(原因),這時候如何整合??

select case 答案 when '1' then '喜歡' when '2' then '不喜歡' when '3' then '還可以' else 答案 end

說明完畢 ^口^/

arrow
arrow
    全站熱搜

    貓小佑 發表在 痞客邦 留言(1) 人氣()