我想获得为特定团队效力且在特定日期之后出生的球员的职业信息。我设法执行以下查询:
select ?playerName ?year ?teamName ?matches ?goals where {
?player a dbo:SoccerPlayer ;
rdfs:label ?playerName ;
dbo:birthDate ?birthDate ;
dbo:careerStation ?station .
?station dbo:years ?year ;
dbo:team ?team ;
dbo:team/rdfs:label ?teamName ;
dbo:numberOfMatches ?matches ;
dbo:numberOfGoals ?goals .
filter (langMatches(lang(?teamName), "EN"))
filter (xsd:date(?birthDate) > "1980-01-01"^^xsd:date)
filter (
?team = <http://dbpedia.org/resource/Olympique_Lyonnais>
|| ?team = <http://dbpedia.org/resource/AS_Monaco_FC>
)
}
order by ?playerName ?year
我的问题是:
某些行与我的过滤器不对应。示例:
"Gaëtan Perrin"@en | 2014... | "Olympique Lyonnais Reserves and Academy"@en | 3 | 1
谢谢您的帮助!
答案 0 :(得分:1)
正如评论中指出的那样,您必须使用子查询来获取所有为这些球队效力并在1980年之后出生的球员。在外部查询中,您可以获取他们的所有职业数据:
select ?playerName ?year ?teamName ?matches ?goals where {
# get all players for given teams born after 1980
{
select distinct ?player {
?player a dbo:SoccerPlayer ;
dbo:birthDate ?birthDate ;
dbo:careerStation/dbo:team ?team
filter (?team in (dbr:Olympique_Lyonnais, dbr:AS_Monaco_FC))
filter (xsd:date(?birthDate) > "1980-01-01"^^xsd:date)
}
}
# get all their career station data
?player a dbo:SoccerPlayer ;
rdfs:label ?playerName ;
dbo:birthDate ?birthDate ;
dbo:careerStation ?station .
?station dbo:years ?year ;
dbo:team ?team ;
dbo:team/rdfs:label ?teamName ;
dbo:numberOfMatches ?matches ;
dbo:numberOfGoals ?goals .
filter (langMatches(lang(?teamName), "EN"))
}
order by ?playerName ?year