neo4j如何使用有条件的地方

发布于 2025-01-24 20:28:36 字数 533 浏览 5 评论 0原文

我有以下查询:

MATCH (u: User {id: '...'})-[r:EXECUTING]->(journey: Journey)
WHERE r.progress > 0 AND r.progress < 100
RETURN journey;

它加载了用附加到用户的所有旅程:执行,如果关系的prempress属性在1到100之间。

现在我想添加一个 - &gt;因此,<代码>其中仅应为r.progress&gt; 0(没有 ...)。 我看到//然后时,有case/,但认为必须有更快的解决方案?

则应检查R.Progress在0到50之间。如果变量为trui,则应将R.Progress检查为0到100之间。

示例“如果某个变量为false ,

I have the following query:

MATCH (u: User {id: '...'})-[r:EXECUTING]->(journey: Journey)
WHERE r.progress > 0 AND r.progress < 100
RETURN journey;

It loads all journeys that are attached to a user with :EXECUTING if the relationship's progress property is between 1 and 100.

Now I want to add a condition for the part behind the AND --> so the WHERE should only be r.progress > 0 (without the AND ...).
I saw that there are CASE/WHEN/THEN but think that there must be a quicker solution?

Example "The where should check r.progress to be between 0 and 50 if a certain variable is false. If the variable is true, it should check r.progress to be between 0 and 100"

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

翻身的咸鱼 2025-01-31 20:28:36

根据您的描述

示例“如果某个变量为false,则应在0到50之间检查R.Progress。如果变量为trui,则应将R.Progress检查为0至100“

。其中子句:

WHERE (
     (variable = FALSE AND (r.progress > 0 AND r.progress < 50 ))
     OR
     (variable = TRUE AND (r.progress > 0 AND r.progress < 100 ))
)

但不确定它比案例/何时“快”。

Based on your description

Example "The where should check r.progress to be between 0 and 50 if a certain variable is false. If the variable is true, it should check r.progress to be between 0 and 100"

I'd write the following WHERE clause:

WHERE (
     (variable = FALSE AND (r.progress > 0 AND r.progress < 50 ))
     OR
     (variable = TRUE AND (r.progress > 0 AND r.progress < 100 ))
)

But not sure it is "quicker" than a CASE/WHEN.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文