Question

I have a SPARQL query to select all resources that has the location "California" within the dbpedia database:

select distinct ?subj where {
 ?subj dbpprop:location dbpedia:California .
} LIMIT 100

Now my problem is to filter this results, so that I only get ?subj that is a sub-class of a certain Class, e.g. dbpedia:Public_company.

I tried sth. like this:

select distinct ?subj where {
 ?subj a dbpedia:Public_company .
 ?subj dbpprop:location dbpedia:California .
} LIMIT 100

but this results in an empty result set.

How can I restrict the ?subj to a be from a certain type of Class?

Was it helpful?

Solution

Your query is the correct way to restrict to instances of a certain class. If you get an empty result set, that simply means that there are no instances found. I briefly looked around in DBPedia and didn't encounter any instances of dbpedia:Public_company. Possibly you have a typo in the class name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top