postgresql的case when查詢

postgresql使用case when來獲取自己需要的值:

case when 條件 then 符合條件輸出的值 else 不符合條件輸出的值 end

select (case when tables.type=1 then tables.title else tables.name end) vals from tables 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章