拥有这个模型:
(:Person)-[:has]-(:Movie)
我需要获得任意一群人拥有的所有电影,但另一部电影却没有。
我开始时:
MATCH (p1.Person {Name: 'Josh'})-[:has]->(m:Movie)
WHERE not exists ((p2:Person {Name: 'Carl'})-[:has]->(m))
RETURN COUNT(m)
我获得了p1拥有的电影数量而p2没有。 问题是我需要与群体相同,而不是个人;类似的东西:
MATCH (p1.Person {Name: ['Josh','Mark]})-[:has]->(m:Movie)
WHERE
not exists ((p2:Person {Name: ['Carl','Roger']})-[:has]->(m))
RETURN COUNT(m)
我需要一个等效的查询来返回Josh AND Mark和Carl AND Roger没有的电影。
任何消化?
答案 0 :(得分:2)
如果您将人名列表作为2 parameters(例如b
和yes
),则可以避免修改Cypher代码以获取不同的名称组合。
例如:
no
MATCH (p1:Person)-[:has]->(m1:Movie)
WHERE p1.Name IN $no
WITH COLLECT(DISTINCT m1) AS blacklist
MATCH (p2:Person)-[:has]->(m2:Movie)
WHERE p2.Name IN $yes AND NOT (m2 IN blacklist)
RETURN COUNT(DISTINCT m2);
关键字用于消除重复项。
答案 1 :(得分:1)
您可以使用WITH
[StreamData]
AS (
SELECT
*
FROM
[DeviceDataStream]
WHERE
[ObjectType] IS NULL -- Filter out device info and command responses
)
SELECT
EventProcessedUtcTime,
PartitionId,
EventEnqueuedUtcTime,
IoTHub,
employee_id,
first_name,
last_name,
age,
salary
INTO
[Telemetry]
FROM
[StreamData]
WHERE type = 'emp' --Table 1
SELECT
EventProcessedUtcTime,
PartitionId,
EventEnqueuedUtcTime,
PersonID,
FirstName,
LastName,
City,
height
INTO
[TelemetryP]
FROM
[StreamData]
WHERE type = 'prsn' --Table 2
谓词:
NONE
答案 2 :(得分:0)
您可以尝试这样的事情:
onItemClick