postgresql使用case when來獲取自己需要的值:
case when 條件 then 符合條件輸出的值 else 不符合條件輸出的值 end
select (case when tables.type=1 then tables.title else tables.name end) vals from tables
postgresql使用case when來獲取自己需要的值:
case when 條件 then 符合條件輸出的值 else 不符合條件輸出的值 end
select (case when tables.type=1 then tables.title else tables.name end) vals from tables