{"id":324,"date":"2020-01-14T09:20:06","date_gmt":"2020-01-14T09:20:06","guid":{"rendered":"http:\/\/wikidata.wwwnlsrc4.supercp.com\/?page_id=324"},"modified":"2020-04-21T12:52:32","modified_gmt":"2020-04-21T12:52:32","slug":"two-or-more-match-patterns","status":"publish","type":"post","link":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/simple-queries\/adding-match-patterns\/two-or-more-match-patterns\/","title":{"rendered":"Two or more match patterns"},"content":{"rendered":"\n<h2>Adding match patterns<\/h2>\n\n\n\n<p>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:<\/p>\n\n\n\n<iframe class=\"\" src=\"https:\/\/query.wikidata.org\/#%23Star%20Wars%20films%0A%0ASELECT%20%3Fitem%20%20%3FitemLabel%20%0AWHERE%20%0A%7B%20%0A%20%20%3Fitem%20wdt%3AP179%20wd%3AQ22092344.%20%23%20item%20is%20part%20of%20the%20series%20Star%20Wars%20%28film%20series%29%0A%20%20%3Fitem%20wdt%3AP57%20wd%3AQ38222.%20%20%20%20%20%23%20item%20has%20director%20property%20with%20value%20George%20Lucas.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%22.%20%7D%0A%7D\" style=\"width:100%;max-width:100%;height:450px\" frameborder=\"0\"><\/iframe>\n\n\n\n<p>The query retrieves four items. These are items that satisfy both conditions. In other words, the patterns have an AND relation between them:<br>?item wdt:P179 wd:Q22092344.<br>AND<br>?item wdt:P57 Q38222.<\/p>\n\n\n\n<h5 id=\"syntax\"># A little bit of syntax<\/h5>\n\n\n\n<p>Another way of formulating the above query, using a semicolon to join the two statements:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror cm-s-eclipse\" data-setting=\"{&quot;mode&quot;:&quot;sparql&quot;,&quot;mime&quot;:&quot;application\/sparql-query&quot;,&quot;theme&quot;:&quot;eclipse&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true}\">#Star Wars films\n\nSELECT ?item  ?itemLabel\nWHERE \n{ \n  ?item wdt:P179 wd:Q22092344; \t# item is part of the series Star Wars (film series)\n  \t   \twdt:P57 wd:Q38222. \t\t# item has director property with value George Lucas.\n  SERVICE wikibase:label { bd:serviceParam wikibase:language &quot;[AUTO_LANGUAGE]&quot;. }\n}\n<\/pre><\/div>\n\n\n\n<p>Because there is a semicolon on line 6, which  joins the two patterns to match, the ?item variable is omitted on line 7.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/324"}],"collection":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/comments?post=324"}],"version-history":[{"count":20,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/324\/revisions"}],"predecessor-version":[{"id":2292,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/324\/revisions\/2292"}],"wp:attachment":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/media?parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/categories?post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/tags?post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}