{"id":339,"date":"2020-01-14T13:58:40","date_gmt":"2020-01-14T13:58:40","guid":{"rendered":"http:\/\/wikidata.wwwnlsrc4.supercp.com\/?page_id=339"},"modified":"2020-11-16T13:51:17","modified_gmt":"2020-11-16T13:51:17","slug":"union-operator","status":"publish","type":"post","link":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/simple-queries\/adding-match-patterns\/union-operator\/","title":{"rendered":"UNION operator"},"content":{"rendered":"\n<h2>Pattern matching with an OR relationship <\/h2>\n\n\n\n<p>In the previous section we saw that if there are two pattern matching conditions, they have an AND relation \u2013 the query will return only those items that match both patterns. If we want to have an OR relation between the conditions, we use the UNION operator. The following query retrieves items that are <strong>either <\/strong>part of the Star Wars film series <strong>or<\/strong> part of the Star Trek film series.<\/p>\n\n\n\n<iframe class=\"\" src=\"https:\/\/query.wikidata.org\/#%23Films%20in%20the%20Star%20Wars%20OR%20Star%20Trek%20film%20series%0A%0ASELECT%20%3Fitem%20%20%3FitemLabel%20%0AWHERE%20%0A%7B%20%0A%20%20%7B%3Fitem%20wdt%3AP179%20wd%3AQ22092344.%7D%20%23%20item%20is%20part%20of%20Star%20Wars%20%28film%20series%29%0A%20%20UNION%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20OR%0A%20%20%7B%3Fitem%20wdt%3AP179%20wd%3AQ1102217.%7D%20%20%20%23%20item%20is%20part%20of%20the%20Star%20Trek%20film%20series%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><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pattern matching with an OR relationship In the previous section we saw that if there are two pattern matching conditions, they have an AND relation \u2013 the query will return only those items that match both patterns. If we want to have an OR relation between the conditions, we use the UNION operator. The following [&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\/339"}],"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=339"}],"version-history":[{"count":5,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"predecessor-version":[{"id":1502,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/339\/revisions\/1502"}],"wp:attachment":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}