Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Im new in cypher queries and I try to return the persons who "PLAYED" a movie and the country where the movie was made
Can someone help me to create a query ?
If what you are looking for is to return the persons who "PLAYED" a movie and the country where the movie was made, you should try something like this:
MATCH (c:Country)<-[:MADE_IN]-(m:Movie)<-[:PLAYED]-(p:Person)
WHERE m.id = "movie_id"
RETURN p,c;
To avoid returning person duplicate you should use the distinct keyword: https://neo4j.com/docs/developer-manual/current/cypher/#return-unique-results
If understand the question correctly, you want
MATCH (n{id:"mySpecialId"})
RETURN n
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I need algorithm that assign object to cluster already created.
In my case objects are Patients or sick person and clusters are diseases, and based on multiple questions patient should be assigned to cluster; of course the questions and responses (yes or no) will be already prepared for every disease.
For example : you are coughing ? if yes => do you have a fever? if Yes then maybe => corona disease.
and so on.
edit : decision tree algorithm
Have a look at ID-3; this allows you to build a decision tree based on pre-classified data, and any new patient can be classified according to their responses.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Query statement
select * from timetables where user_id IN
(SELECT user_id FROM timetables GROUP BY user_id HAVING COUNT(*) > 1)
I don't want to use find_by_sql.
because find_by_sql returns array.
I want like to use a mixture of (.where, .group, .having...)
help me...
The problem with this approach is that the result of subquery would be interpreted by ruby, not by MySQL, drastically slowing down the performance, but here you go:
Timetable.where(user_id: Timetable.group(:user_id)
.having('count(*) > 1')
.pluck(:user_id))
#⇒ Timetable::FriendlyIdActiveRecordRelation < ActiveRecord::Relation
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am using Neo4j graph database.
I want to disconnect 2 nodes if they are connected by any relationship.
How to do that ?
Get your nodes somehow. This example assumes you have an Id parameter on the nodes. (but you can use any parameter to get a match)
match (n:SomeLabel)-[r]-(m:AnotherLabel) where m.Id =1, n.Id =2 delete r
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Consider Item model that may have zero or more variations, how can I found first item which have some variations?
class Item
has_many :variations
end
So item.variations is not nil.
Something like:
Item.with_not_nil_variations.first
If your item has many variations, what you want is a SQL INNER JOIN.
In rails you can do it using joins :
Item.joins(:variations).first
The generated SQL will contain an INNER JOIN, meaning that it will return the Items having a variation. Before the first you can add on order(), that will allow you to have more control on the first items with variations that will be returned.
Do not use includes as it is translated to a left outer join, and it is definitely not what you want.
An inner join should do this for you:
Item.joins(:variations).first
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to write something like this
User.groups.members.addresses
What I need is an array of all addresses which User has access to. If User is in two groups, each group has 2 unique members with unique addresses I want an array of 4 addresses
Using Ruby on rails 4
You should be able to add a scope to your address model, you just need to add some joins in there. Haven't tested this but it should be on the right track.
class Address
scope :by_user, -> user { joins(:member).joins(:group).where(user: {id: user.id})}}
end
usage:
Address.by_user(#user)