Skip to content

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:

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