Have you tried removing "LIMIT 1"? Of course, the data has to be there too.
Cheers,
Simeon
On Mon, Apr 7, 2025, 8:27 AM Eric Lease Morgan <
[log in to unmask]> wrote:
> How do I use SPARQL to query WikiData and get all of Abraham Lincoln's
> occupations?
>
> The WikiData QNumber for Abraham Lincoln is Q91, and therefore his
> WikiData page can be seen here:
>
> https://www.wikidata.org/wiki/Q91
>
> The following SPARQL query returns a label, a description, a gender, and a
> single occupation for President Lincoln:
>
> SELECT ?label ?description ?genderLabel ?occupationLabel
> WHERE {
> wd:Q91 rdfs:label ?label .
> wd:Q91 schema:description ?description .
> wd:Q91 wdt:P21 ?gender .
> wd:Q91 wdt:P106 ?occupation .
> FILTER ( langMatches( lang( ?label ), "en" ) )
> FILTER ( langMatches( lang( ?description ), "en" ) )
> SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' . }
> }
> LIMIT 1
>
> But President Lincoln had many occupations. How do I change the query to
> return all of the occupations he had? In other words, when there is a
> one-to-many relationship between a subject and objects, how do I get all
> the objects? This is akin to getting all of the subjects for a given book.
>
> --
> Eric Morgan
> Navari Family Center for Digital Scholarship
> Hesburgh Libraries
> University of Notre Dame
>
|