0
我無法將爲MySQL設計的SQL查詢翻譯成Postgres語法。這是查詢:Postgres中的IF-ELSE
select if(sendonly = true, 'REJECT', 'OK') AS access from accounts where username = '%u' and domain = '%d' and enabled = true LIMIT 1;
這個漂亮的小函數「if()」在Postgres中不可用。我第一次嘗試使用某些CASE子句失敗。需要修改哪些內容才能在Postgres中運行此查詢?
你有沒有做任何研究?使用Google搜索「postgres if else」會顯示https://www.postgresql.org/docs/9.1/static/plpgsql-control-structures.html,它表示有一個「IF-THEN-ELSE」結構。 – ceejayoz
@ceejayoz你可能想看看頁面更接近一點,那是關於服務器端PL/pgSQL語言,而不是SQL查詢。 –