Basic

Omission

Use blank nodes and anonymous patterns. When you need to traverse through intermediate nodes without caring about their values, blank nodes keep queries clean.

Understanding Blank Nodes

Blank nodes (written as [] or _:name) represent intermediate values you don't need to see in results. They're useful when you care about a relationship existing but not about the connecting node's identity.

Anonymous Blank Nodes []

Has Any Value for Property
Run ↗
SELECT ?item ?itemLabel
WHERE {
  ?item wdt:P31 wd:Q5 ;
        wdt:P2534 [] .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
LIMIT 20

The [] means "some value exists". This finds humans with a defining formula (P2534) without caring what the formula is. It's equivalent to using a variable you never reference: wdt:P2534 ?unused.

Traverse Without Binding
Run ↗
SELECT ?person ?personLabel
WHERE {
  ?person wdt:P31 wd:Q5 ;
          wdt:P800 [ wdt:P577 [] ] .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
LIMIT 20

Nested blank nodes traverse multiple relationships. This finds people with notable works (P800) that have publication dates (P577), without binding the work or date to variables. Only the person is returned.

Blank Node Properties

Multiple Properties on Blank Node
Run ↗
SELECT ?country ?countryLabel
WHERE {
  ?country wdt:P31 wd:Q6256 ;
           wdt:P36 [ wdt:P31 wd:Q515 ; wdt:P1082 ?pop ] .
  FILTER(?pop > 5000000)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Blank nodes can have multiple properties listed with semicolons, just like regular subjects. This finds countries whose capital is a city with population over 5 million. The capital city itself isn't returned—only the country.

Comparing to Variables

Equivalent with Variable
Run ↗
SELECT ?country ?countryLabel
WHERE {
  ?country wdt:P31 wd:Q6256 ;
           wdt:P36 ?capital .
  ?capital wdt:P31 wd:Q515 ;
           wdt:P1082 ?pop .
  FILTER(?pop > 5000000)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

This is equivalent to the previous query but uses an explicit ?capital variable. Use blank nodes when the intermediate value isn't needed in results or for reference elsewhere. Use variables when you need to return or reuse the value.

Key Entities Used in Examples

Entity ID Description
human wd:Q5 Any human being
country wd:Q6256 Sovereign state
city wd:Q515 Large human settlement
defining formula wdt:P2534 Mathematical formula defining something
notable work wdt:P800 Notable work by a person
publication date wdt:P577 Date of first publication
capital wdt:P36 Seat of government
population wdt:P1082 Number of inhabitants