Skip to main content

Optional Clauses

Within the WHERE clause, you may include OPTIONAL clauses. For example, the below query will return all persons and handles, including those persons that may not have favorite numbers.

SELECT ?person ?handle ?nums
WHERE {
?person fd:person/handle ?handle.
OPTIONAL{?person fd:person/favNums ?nums.}
}

Write Your Own!

How would you write a query that returns all persons and `person/fullNames`, and optionally returns `person/favArtists` if that person has favorite artists?