Search code examples
sparqlowlontologyprotege

sparql query to get all individual of specific class using data value


I have an ontology that contains two classes (course,lesson) the course has a data properties called code of type string

How to get all individuals from specific class with specific data properties value

here is a screenshot

enter image description here


Solution

  • The general pattern is something like this:

    SELECT ?individual
    WHERE { ?individual a <uri-of-specific-class> ;
                        <uri-of-property> ?propertyValue .
            FILTER(STR(?propertyValue) = "expected value")
    }
    

    You will need to adapt this with the details of your specific ontology (the URIs of your class names and properties), but it shows the general approach. I would also suggest that you try out a SPARQL tutorial, there's several good ones online for you to find.