From W3C Wiki
There are several ways in which a SPARQL (sub)query might be embedded in another query.
- A) A
SELECTquery could be embedded in a query's query pattern, joining its bindings with those of the parent query.
- B) A
ASKquery could be used in a
FILTERas a boolean condition (perhaps combined with an
- C) A
DESCRIBEquery could be used in a
FROM NAMEDclause to supply part of a query's RDF dataset.
- D) OpenLink Virtuoso supports
SELECTsubqueries in all places where group patterns are allowed. Virtuoso also supports the
ASkeyword to rename expression as bindings that can be joined with and projected in a parent query. Future versions of Virtuoso will support the second two subquery forms mentioned above. Virtuoso also intends to implement named SPARQL views that will be similar to named SQL views; these views will be implemented as macros so any given occurrence of a view in a query will be replaced with occurrence of the body of the view in same place (with adjusted variable names). If implemented this way, view declarations can not contain invocations of the view itself, but this limitation will allow a global optimization of the query with all invoked views without writing full-scale DATALOG infrastructure.