SPARQL仅返回具有许多属性值的类的一个实例

时间:2018-02-28 14:29:43

标签: sparql

使用SPARQL查询图表。某些类具有包含许多值的属性,并使用不同的值组合返回相同的类。

<http://example.org/hospital/Queen_Charlotte's_Hospital> a foaf:Organization ;
    dbo:City "London" ;
    dbo:county "Greater_London" ;
    geo:lat "51.516525268554688" ;
    geo:long "-0.23664399981498718" ;
    org:OrganizationalUnit "Hospital" ;
    org:hasSubOrganization "Hospital" ;
    foaf:address "Du_Cane_Road" ;
    foaf:homepage "http://www.imperial.nhs.uk/qcch/index.htm" ;
    foaf:mbox "" ;
    foaf:name "Queen_Charlotte's_Hospital" ;
    foaf:phone "020_3313_1111" .

<http://example.org/hospital/Queen_Elizabeth_Hospital> a foaf:Organization ;
    dbo:City "Birmingham",
        "Gateshead",
        "London" ;
    dbo:county "",
        "Tyne_and_Wear",
        "West_Midlands" ;
    geo:lat "51.47857666015625",
        "52.451946258544922",
        "54.938899993896484" ;
    geo:long "-1.581035852432251",
        "-1.9396553039550781",
        "4.8706158995628357E-2" ;
    org:OrganizationalUnit "Hospital" ;
    org:hasSubOrganization "Hospital" ;
    foaf:address "Queen_Elizabeth_Medical_Centre",
        "Sheriff_Hill",
        "Stadium_Road" ;
    foaf:homepage "",
        "http://www.qegateshead.nhs.uk",
        "http://www.uhb.nhs.uk" ;
    foaf:mbox "",
        "communications@uhb.nhs.uk",
        "pals@ghnt.nhs.uk" ;
    foaf:name "Queen_Elizabeth_Hospital" ;
    foaf:phone "0121_627_2000",
        "0191_482_0000",
        "020_8836_6000" .

我怎样才能使这个查询只返回每个类的一个实例,即使它具有多个值的属性?

SELECT DISTINCT ?x ?name ?city ?county ?phone ?email ?address ?lat ?long 
WHERE{
  ?x a foaf:Organization ;
       foaf:name ?name ;
       dbo:City ?city ;
       dbo:county ?county ;
       foaf:mbox ?email ;
       foaf:address ?address ;
       foaf:phone ?phone ;
       geo:lat ?lat ;
       geo:long ?long .
}

例如,我只想要返回一个<http://example.org/hospital/Queen_Elizabeth_Hospital>实例。

0 个答案:

没有答案