I was attempting to write a query to get, given an actor, the actors that were cast members in the same movies (s)he played in.
The following query gives me the movies the actor played in.
SELECT distinct ?actorLabel ?movieLabel ?boxOffice
WHERE {
{
SELECT ?actor WHERE {
?actor rdfs:label "Johnny Depp"@en.
?actor wdt:P106 ?occupation.
?occupation wdt:P279+ wd:Q33999.
}
}
?movie wdt:P161 ?actor.
?movie wdt:P2142 ?boxOffice.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?boxOffice)
limit 10
so now i want to get all the related actors from each of those movies. i attempted to do this with a subquery as such
SELECT distinct ?actorLabel ?movieLabel ?boxOffice ?relatedActor ?relatedActorLabel
WHERE {
{
SELECT ?actor WHERE {
?actor rdfs:label "Johnny Depp"@en.
?actor wdt:P106 ?occupation.
?occupation wdt:P279+ wd:Q33999.
}
}
?movie wdt:P161 ?actor.
?movie wdt:P2142 ?boxOffice.
{
SELECT ?relatedActor WHERE {
?movie wdt:P161 ?relatedActor
}
limit 5
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?boxOffice)
limit 10
but for some reason i don't understand i keep getting Barack Obama
and Douglas Adams
as the only results. even when starting from completely different actors.
Can anyone shed some light on this, what am i doing wrong?