Two or more match patterns

Adding match patterns

Until now our queries had only one pattern matching condition. For example, they selected items that have a P179 property (part of a series) with a value of Q22092344 (Star Wars film series). In the following query, there are two pattern matching conditions:

The query retrieves four items. These are items that satisfy both conditions. In other words, the patterns have an AND relation between them:
?item wdt:P179 wd:Q22092344.
AND
?item wdt:P57 Q38222.

# A little bit of syntax

Another way of formulating the above query, using a semicolon to join the two statements:

#Star Wars films

SELECT ?item  ?itemLabel
WHERE 
{ 
  ?item wdt:P179 wd:Q22092344; 	# item is part of the series Star Wars (film series)
  	   	wdt:P57 wd:Q38222. 		# item has director property with value George Lucas.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}

Because there is a semicolon on line 6, which joins the two patterns to match, the ?item variable is omitted on line 7.

Skip to content