Chapter 1

Basic SPARQL Queries

Master the foundational building blocks of SPARQL. Learn to select, filter, and shape your queries to extract meaningful data from knowledge graphs.

15+
Topics
20+
Examples
Beginner
Level

Getting Started

This chapter covers the essential SPARQL concepts you need to start querying knowledge graphs effectively. Each topic builds on the previous one, taking you from simple selections to complex pattern matching.

All examples use Wikidata as the data source, so you can run them directly on the Wikidata Query Service to see real results.

Topics

Quick Reference

Here's a simple query demonstrating several basic concepts together:

Complete Basic Query Example
# Find programming languages created after 2000
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>

SELECT DISTINCT ?lang ?langLabel ?inception
WHERE {
  ?lang wdt:P31 wd:Q9143 .        # instance of programming language
  ?lang wdt:P571 ?inception .      # has inception date

  FILTER(YEAR(?inception) > 2000)

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
ORDER BY DESC(?inception)
LIMIT 10

This query selects entities where wdt:P31 (instance of) equals wd:Q9143 (programming language), and their inception dates (wdt:P571), filters to dates after 2000, and returns unique results with English labels via wikibase:label, sorted by newest first and capped at 10 rows.

Key Concepts Demonstrated

What's Next?

After mastering basic queries, continue your journey with these chapters:

🔢

Expressions

Learn string manipulation, date functions, and mathematical operations.

Continue
📊

Aggregate Queries

Analyze data with COUNT, SUM, AVG, and GROUP BY.

Continue