{"id":8624,"date":"2022-02-24T15:28:49","date_gmt":"2022-02-24T20:28:49","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=8624"},"modified":"2022-02-24T15:28:49","modified_gmt":"2022-02-24T20:28:49","slug":"postgresql-matching-functions","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=8624","title":{"rendered":"PostgreSQL Matching Functions"},"content":{"rendered":"<h2 id=\"PostgreSQLCommands-QueriesusingPOSIXregex\">Queries using <a class=\"external-link\" href=\"https:\/\/www.postgresql.org\/docs\/9.3\/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" target=\"_blank\" rel=\"nofollow noopener\" data-ext-link-init=\"true\">POSIX regex<\/a><\/h2>\n<pre>-- Case insensitive match\r\nSELECT * FROM mytable WHERE columnName ~* 'this|that';<\/pre>\n<pre>-- Case sensitive match\r\nSELECT * FROM mytable WHERE columnName ~ 'this|that';<\/pre>\n<h2 id=\"PostgreSQLCommands-QueriesUsingANY\">Queries Using <a class=\"external-link\" href=\"https:\/\/www.postgresql.org\/docs\/current\/functions-comparisons.html#id-1.5.8.30.16\" target=\"_blank\" rel=\"nofollow noopener\" data-ext-link-init=\"true\">ANY<\/a><\/h2>\n<pre>SELECT * FROM mytable WHERE columnName like any (array['%this%', '%that%']);<\/pre>\n<h2 id=\"PostgreSQLCommands-QueriesUsingSIMILARTO\">Queries Using <a class=\"external-link\" href=\"https:\/\/www.postgresql.org\/docs\/9.0\/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP\" target=\"_blank\" rel=\"nofollow noopener\" data-ext-link-init=\"true\">SIMILAR TO<\/a><\/h2>\n<pre>-- This is translated to a regex query internally, so not effectively different than constructing the regex query yourself\r\nSELECT * FROM mytable WHERE columnName SIMILAR TO '%(this|that)%';<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Queries using POSIX regex &#8212; Case insensitive match SELECT * FROM mytable WHERE columnName ~* &#8216;this|that&#8217;; &#8212; Case sensitive match SELECT * FROM mytable WHERE columnName ~ &#8216;this|that&#8217;; Queries Using ANY SELECT * FROM mytable WHERE columnName like any (array[&#8216;%this%&#8217;, &#8216;%that%&#8217;]); Queries Using SIMILAR TO &#8212; This is translated to a regex query internally, so &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1522],"tags":[1349,922],"class_list":["post-8624","post","type-post","status-publish","format-standard","hentry","category-postgresql","tag-postgresql","tag-sql"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8624"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8624\/revisions"}],"predecessor-version":[{"id":8625,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/8624\/revisions\/8625"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}