{"id":1201,"date":"2024-12-23T09:44:18","date_gmt":"2024-12-23T02:44:18","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=1201"},"modified":"2025-01-03T14:22:39","modified_gmt":"2025-01-03T07:22:39","slug":"postgresql-similar-to","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/","title":{"rendered":"PostgreSQL SIMILAR TO Operator"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the PostgreSQL <code>SIMILAR TO<\/code> operator to search for a specific pattern in a column that matches a regular expression.<\/p>\n\n\n\n<p class=\"note\">Please note that you need a basic understanding of <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-regular-expressions\/\">regular expressions<\/a> to continue this tutorial.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='overview-of-the-postgresql-similar-to-operator'>Overview of the PostgreSQL SIMILAR TO Operator <a href=\"#overview-of-the-postgresql-similar-to-operator\" class=\"anchor\" id=\"overview-of-the-postgresql-similar-to-operator\" title=\"Anchor for Overview of the PostgreSQL SIMILAR TO Operator\">#<\/a><\/h2>\n\n\n\n<p>In PostgreSQL, the <code>SIMILAR TO<\/code> operator returns true if the regular expression matches the whole string.<\/p>\n\n\n\n<p>Here&#8217;s the syntax of the <code>SIMILAR TO<\/code> operator:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  column1,\n  column2\n<span class=\"hljs-keyword\">FROM<\/span>\n  <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">WHERE<\/span>\n  column1 <span class=\"hljs-keyword\">SIMILAR<\/span> <span class=\"hljs-keyword\">TO<\/span> pattern;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, the <code>SIMILAR TO<\/code> operator returns true only if the value in the pattern matches the entire value in <code>column1<\/code>, or false otherwise. <\/p>\n\n\n\n<p>It differs from the expected behavior of matching a string with a regular expression, which can match any part of a string.<\/p>\n\n\n\n<p>Besides metacharacters used in a regular expression, you can use the <code>_<\/code> and <code>%<\/code> wildcard characters to denote a single character and zero or more characters, respectively. <\/p>\n\n\n\n<p>Typically, the dot (<code>.<\/code>) character is a metacharacter that matches any single character except the newline, but the <code>SIMILAR TO<\/code> operator does not treat it as a metacharacter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='example-of-postgresql-similar-to-operator'>Example of PostgreSQL SIMILAR TO Operator <a href=\"#example-of-postgresql-similar-to-operator\" class=\"anchor\" id=\"example-of-postgresql-similar-to-operator\" title=\"Anchor for Example of PostgreSQL SIMILAR TO Operator\">#<\/a><\/h2>\n\n\n\n<p>Let&#8217;s take some examples of using the <code>SIMILAR TO<\/code> operator with the <code>products<\/code> table:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"159\" height=\"254\" src=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png\" alt=\"PostgreSQL SIMILAR TO operator sample table\" class=\"wp-image-1051\"\/><\/figure>\n\n\n\n<p>The following <code>SELECT<\/code> statement uses the <code>SIMILAR TO<\/code> operator to select products with names that match a regular expression:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  product_name\n<span class=\"hljs-keyword\">FROM<\/span>\n  products\n<span class=\"hljs-keyword\">WHERE<\/span>\n  product_name <span class=\"hljs-keyword\">SIMILAR<\/span> <span class=\"hljs-keyword\">TO<\/span> <span class=\"hljs-string\">'\\w+\\s*(Galaxy|iPhone)\\s*\\w+'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIHByb2R1Y3RfbmFtZSBGUk9NIHByb2R1Y3RzIFdIRVJFIHByb2R1Y3RfbmFtZSBTSU1JTEFSIFRPICdcdytccyooR2FsYXh5fGlQaG9uZSlccypcdysnOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">    product_name\n<span class=\"hljs-comment\">--------------------<\/span>\n Samsung Galaxy S24\n Apple iPhone <span class=\"hljs-number\">15<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Let&#8217;s break down the regular expression <code>'\\w+\\s*(Galaxy|iPhone)\\s*\\w+'<\/code>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\\w+<\/code> matches one or more words.<\/li>\n\n\n\n<li><code>\\s*<\/code> matches zero or more spaces.<\/li>\n\n\n\n<li><code>(Galaxy|iPhone)<\/code> matches either the word Galaxy or iPhone.<\/li>\n\n\n\n<li><code>\\s*<\/code> matches zero or more spaces.<\/li>\n\n\n\n<li><code>\\w+<\/code> matches one or more words.<\/li>\n<\/ul>\n\n\n\n<p>So, the regular expression matches any product name that starts with one or more words, a space, either Galaxy or iPhone, a space, and one or more words.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='using-not-similar-to-operator'>Using NOT SIMILAR TO Operator <a href=\"#using-not-similar-to-operator\" class=\"anchor\" id=\"using-not-similar-to-operator\" title=\"Anchor for Using NOT SIMILAR TO Operator\">#<\/a><\/h2>\n\n\n\n<p>To negate the <code>SIMILAR TO<\/code> operator, you use the <code>NOT<\/code> operator:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  column1,\n  column2\n<span class=\"hljs-keyword\">FROM<\/span>\n  <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">WHERE<\/span>\n  column1 <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">SIMILAR<\/span> <span class=\"hljs-keyword\">TO<\/span> pattern;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>NOT SIMILAR TO<\/code> operator returns <code>true<\/code> if the value in <code>column1<\/code> does not match the pattern or <code>false<\/code> otherwise.<\/p>\n\n\n\n<p>For example, the following query uses the <code>NOT SIMILAR TO<\/code> operator to retrieve the product names for all products with names that do not end with one or more digits:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  product_name\n<span class=\"hljs-keyword\">FROM<\/span>\n  products\n<span class=\"hljs-keyword\">WHERE<\/span>\n  product_name <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">SIMILAR<\/span> <span class=\"hljs-keyword\">TO<\/span> <span class=\"hljs-string\">'%\\d+'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIHByb2R1Y3RfbmFtZSBGUk9NIHByb2R1Y3RzIFdIRVJFIHByb2R1Y3RfbmFtZSBOT1QgU0lNSUxBUiBUTyAnJVxkKyc7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">       product_name\n<span class=\"hljs-comment\">---------------------------<\/span>\n Sony Xperia <span class=\"hljs-number\">1<\/span> VI\n Apple iPhone <span class=\"hljs-number\">15<\/span> Pro Max\n Sony Bravia XR A95K\n Samsung QN900C Neo QLED\n LG G3 OLED\n Sony HT-A7000 Soundbar\n Bose SoundLink Max\n Lenovo ThinkPad X1 Carbon\n Apple iMac <span class=\"hljs-number\">24<\/span>\"<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>%<\/code> matches zero or more characters. Note that the <code>%<\/code> is the wildcard character, not the metacharacter used in the regular expression.<\/li>\n\n\n\n<li><code>\\d+<\/code> matches one or more digits.<\/li>\n<\/ul>\n\n\n\n<p>The pattern <code>'%\\d+'<\/code> matches any strings that start with zero or more characters and end with one or more digits. The <code>NOT SIMILAR TO<\/code> returns the products whose names do not end with digits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='using-escape-in-similar-to-operator'>Using ESCAPE in SIMILAR TO Operator <a href=\"#using-escape-in-similar-to-operator\" class=\"anchor\" id=\"using-escape-in-similar-to-operator\" title=\"Anchor for Using ESCAPE in SIMILAR TO Operator\">#<\/a><\/h2>\n\n\n\n<p>Like the <code><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-like\/\">LIKE<\/a><\/code> operator, you can use the <code>ESCAPE<\/code> option to define an escape character in the pattern when using the <code>SIMILAR TO<\/code> operator:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  column1,\n  column2\n<span class=\"hljs-keyword\">FROM<\/span>\n  <span class=\"hljs-built_in\">table_name<\/span>\n<span class=\"hljs-keyword\">WHERE<\/span>\n  column1 <span class=\"hljs-keyword\">SIMILAR<\/span> <span class=\"hljs-keyword\">TO<\/span> pattern <span class=\"hljs-keyword\">ESCAPE<\/span> escape_character;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following statement uses the <code>SIMILAR TO<\/code> with the <code>ESCAPE<\/code> option to find products whose descriptions contain the character <code>%<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  product_name,\n  description\n<span class=\"hljs-keyword\">FROM<\/span>\n  products\n<span class=\"hljs-keyword\">WHERE<\/span>\n  description <span class=\"hljs-keyword\">SIMILAR<\/span> <span class=\"hljs-keyword\">TO<\/span> <span class=\"hljs-string\">'%$%%*'<\/span> <span class=\"hljs-keyword\">ESCAPE<\/span> <span class=\"hljs-string\">'$'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIHByb2R1Y3RfbmFtZSwgZGVzY3JpcHRpb24gRlJPTSBwcm9kdWN0cyBXSEVSRSBkZXNjcmlwdGlvbiBTSU1JTEFSIFRPICclJCUlKicgRVNDQVBFICckJzs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first and last <code>%<\/code> characters are wildcard characters.<\/li>\n\n\n\n<li>The second <code>%<\/code> is the wildcard, but we want to treat it as a regular character. To do that, we specify an escape character <code>$<\/code> in the <code>ESCAPE<\/code> option and use the escape character <code>$<\/code> right before the <code>%<\/code> in the pattern.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>SIMILAR TO<\/code> operator to search for a value that matches a regular expression.<\/li>\n\n\n\n<li>Use the <code>NOT<\/code> operator to negate the result of the <code>SIMILAR TO<\/code> operator.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='quiz'>Quiz <a href=\"#quiz\" class=\"anchor\" id=\"quiz\" title=\"Anchor for Quiz\">#<\/a><\/h2>\n\n\n\n<iframe loading=\"lazy\"\n  name=\"quiz\"\n  src=\"\/quiz\/?quiz=similar-to\"\n  height=\"700\"\n  width=\"600\"\n  class=\"iframe\"\n><\/iframe>\n\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1201\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL SIMILAR TO Operator\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1201\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL SIMILAR TO Operator\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>You&#8217;ll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":76,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1201","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL SIMILAR TO Operator<\/title>\n<meta name=\"description\" content=\"You&#039;ll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL SIMILAR TO Operator\" \/>\n<meta property=\"og:description\" content=\"You&#039;ll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-03T07:22:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png\" \/>\n\t<meta property=\"og:image:width\" content=\"159\" \/>\n\t<meta property=\"og:image:height\" content=\"254\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/\",\"name\":\"PostgreSQL SIMILAR TO Operator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/products.png\",\"datePublished\":\"2024-12-23T02:44:18+00:00\",\"dateModified\":\"2025-01-03T07:22:39+00:00\",\"description\":\"You'll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/products.png\",\"contentUrl\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/products.png\",\"width\":159,\"height\":254,\"caption\":\"PostgreSQL Expression Index\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-similar-to\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Tutorial\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL SIMILAR TO Operator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL SIMILAR TO Operator","description":"You'll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL SIMILAR TO Operator","og_description":"You'll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-01-03T07:22:39+00:00","og_image":[{"width":159,"height":254,"url":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/","url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/","name":"PostgreSQL SIMILAR TO Operator","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/#primaryimage"},"image":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","datePublished":"2024-12-23T02:44:18+00:00","dateModified":"2025-01-03T07:22:39+00:00","description":"You'll learn how to use the PostgreSQL SIMILAR TO operator to search for a specific pattern in a column that matches a regular expression.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/#primaryimage","url":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","contentUrl":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","width":159,"height":254,"caption":"PostgreSQL Expression Index"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-similar-to\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Tutorial","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL SIMILAR TO Operator"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=1201"}],"version-history":[{"count":7,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1201\/revisions"}],"predecessor-version":[{"id":1400,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1201\/revisions\/1400"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=1201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}