Intro to SPARQL (Part 2)

OPTIONAL, DISTINCT, LIMIT, OFFSET and ORDERBY keywords.

DISTINCT and OPTIONAL keywords.

Necessarily, DISTINCT keyword is used in SPARQL to eliminate the duplicates same as in MYSQL. OPTIONAL keyword is used to query data that may or may not be exist in the results. Let me explain with examples.

query without DISTINCT keyword
query with DISTINCT keyword
query with OPTIONAL

LIMIT , OFFSET and ORDER BY keywords.

Usage is very similar to that of MYSQL queries. LIMIT keyword is used to get a specific number of results. OFFSET keyword allows to skip certain number of results and show the result starting from the next value. Finally ORDER BY is used to order the results according to a specified order of certain field.

query with LIMIT
query with OFFSET
query with ORDER BY
ordered in descending order
ordered in alphabetical order

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store