Manoj Deshpande
Manoj Deshpande

Reputation: 311

How to write Sparql query for the following result?

enter image description here[![SPARQL Query Details][2]][2]

How should I write SPARQL query to get the details from node2 : URI for node2 is same in both the graphs and URI for node 1 is different. Thank you in advance.

as such, I need below details.

node2 def
hasID ghi
hasvertex jkl
hasLastname mno

Upvotes: 0

Views: 140

Answers (2)

Nicholas Car
Nicholas Car

Reputation: 1251

Just alter that SPARQL slightly to use real URIs for properties:

SELECT ?node2 ?p ?o
WHERE {
  <http://ex/node1> <http://ex/hasName> ?node2 .
  ?node2 ?p ?o .
}

Upvotes: 1

Pascalco
Pascalco

Reputation: 2836

To get all triples write SELECT ?node2 ?p ?o WHERE {?node2 ?p ?o}.

Now to restrict the results to graph 1 (defined by the URI of node1) you need to add <http://ex/abc> hasName ?node2.

Together:

SELECT ?node2 ?p ?o WHERE{
  <http://ex/abc> hasName ?node2 .
  ?node2 ?p ?o
}

Upvotes: 1

Related Questions