how to get all of abraham lincoln's occupations

From: Eric Lease Morgan <00000107b9c961ae-dmarc-request_at_nyob>
Date: Mon, 7 Apr 2025 09:26:35 -0400
To: CODE4LIB_at_LISTS.CLIR.ORG
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
Received on Mon Apr 07 2025 - 09:25:36 EDT