英文:
Postgres CASE expression then null
问题
The Chinese translation of the provided content is as follows:
以下查询是我在我的应用程序中获得的选择查询的一部分
其中
如果 o.tracking_id <> '0' 则 a.account_id 为 null
和
o.status = 'N'
否则
o.tracking_id = '0'
和
o.status = 'N'
我很难理解下面这行的意思
你能告诉我这到底是什么意思吗?
case when o.tracking_id <> '0' then a.account_id is null
英文:
The below query is part of a select query which I have got in my application
where
case when o.tracking_id <> '0' then a.account_id is null
and
o.status = 'N'
else
(
o.tracking_id = '0'
and
o.status = 'N'
)
END
I am having hardtime to understand the below line
Can you please tell me what does this exactly mean ?
case when o.tracking_id <> '0' then a.account_id is null
答案1
得分: 0
我不会在这里使用 CASE
表达式,而是会使用以下逻辑:
WHERE
(o.tracking_id <> '0' AND a.account_id IS NULL AND o.status = 'N')
OR
(o.tracking_id = '0' AND o.status = 'N')
英文:
I wouldn't use a CASE
expression here but instead would use the following logic:
<!-- language: sql -->
WHERE
(o.tracking_id <> '0' AND a.account_id IS NULL AND o.status = 'N')
OR
(o.tracking_id = '0' AND o.status = 'N')
答案2
得分: 0
条件写得有些笨拙。等价于这个更易读的表达式:
where (o.tracking_id = '0' or a.account is null)
and o.status = 'N';
英文:
The condition is written somewhat clumsily. It is equivalent to this more readable expression:
where (o.tracking_id = '0' or a.account is null)
and o.status = 'N';
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论