postgresql 如果选择查询中的条件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6057625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:56:50 来源:igfitidea点击:
If condition in select query
提问by Rafiu
select email from mailing list
This is the query i want to use if
condition. I have a column in mailing list as unsub
. If this unsub
is true
the email should null in the selected result otherwise the email will be the selected result
这是我想使用if
条件的查询。我在邮件列表中有一个列作为unsub
. 如果这unsub
是true
电子邮件在所选结果中应为空,否则电子邮件将是所选结果
回答by davek
select case unsub when true then null else email end as email,....
from ...