I have a db of drugs and manufacturers and I want to find all manufacturers who have produced multiple drugs. How can I get only the manufacturers and the drugs they have produced?
I'm currently using
match (a:Brand), (c:Manufacturer) where size((c)-[:PRODUCED]->()) >1 return a,c;
which returns manufacturers with more than one drug produced but also all drugs, regardless of manufacturer
This query uses the aggregating function , COLLECT
, to return a record for each manufacturer who makes multiple brands, along with a collection of those brands:
MATCH (m:Manufacturer)-[:PRODUCED]->(b:Brand)
WITH m, COLLECT(b) AS brands
WHERE SIZE(brands) > 1
RETURN m, brands;
听起来您只需要选择制造商,就像这样:
MATCH (c:Manufacturer) WHERE size((c)-[:PRODUCED]->()) > 1 RETURN c;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.