{"id":8422,"date":"2021-01-19T07:39:00","date_gmt":"2021-01-19T07:39:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8422"},"modified":"2025-09-01T05:07:36","modified_gmt":"2025-09-01T05:07:36","slug":"how-to-check-if-postgresql-array-contains-value","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/","title":{"rendered":"How to Check if PostgreSQL Array Contains Value"},"content":{"rendered":"\n<p>PostgreSQL is a popular database that supports a vast range of data types including arrays. While working array columns, database programmers and software developers may need to check if value exists in PostgreSQL array. It can be really difficult to implement this on your own without any available operators and functions. Luckily, there are several ways to do this in PostgreSQL. In this article we will look at how to check if PostgreSQL array contains value.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#How_to_Check_if_PostgreSQL_Array_Contains_Value\" >How to Check if PostgreSQL Array Contains Value<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#1_Using_ANY_Function\" >1. Using ANY() Function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#2_Using_ALL_Operator\" >2. Using ALL Operator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#3_Using_Contains_Operator\" >3. Using Contains Operator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#4_Using_Overlap_Operator\" >4. Using Overlap Operator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#Check_Value_in_Array_Using_Ubiq\" >Check Value in Array Using Ubiq<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Check_if_PostgreSQL_Array_Contains_Value\"><\/span>How to Check if PostgreSQL Array Contains Value<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It is very easy to check if a value is present in a PostgreSQL column when it is a string, text or varchar data type, but it can be tricky to do this in array. If you are a beginner database developer, you may end up using IN operator as shown below. But it only works with a set of strings, not an array or number or strings.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT * FROM customers WHERE country IN ('India', 'US', 'UK');<\/pre>\n\n\n\n<p>Here are the different ways to update array in PostgreSQL. Let us say you have the following array column.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <code>create table employees ( <\/code>\n     <code>id int, <\/code>\n     <code>name varchar, <\/code>\n     <code>sales <strong>integer[] <\/strong><\/code>\n<code>);<\/code><\/pre>\n\n\n\n<p>In the above example, we have created column <em>sales<\/em> as an array of integers.<\/p>\n\n\n\n<p>Let us also insert data in our array column.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># insert into employees (id, name, sales)\n          values (1, ' John Doe', ARRAY [9,7,5,4,3,2]),\n                 (2, ' Jim Day', ARRAY [8,6,3,2,9,2]);\n\n# select * from employees;\n id |   name    |     sales\n----+-----------+---------------\n  1 |  John Doe | {9,7,5,4,3,2}\n  2 |  Jim Day  | {8,6,3,2,9,2}<\/pre>\n\n\n\n<p>There are several ways to find if an array contains a value. We will look at each of them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_ANY_Function\"><\/span>1. Using ANY() Function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The ANY function allows you to quickly compare a column value with an array of other values. It returns true if there is a match, else it returns false. Here is the syntax of ANY function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>value = ANY (array)<\/code><\/pre>\n\n\n\n<p>In the above statement, you need to specify the value you want to check and the array in which you want to check its presence\/absence. You can specify ANY function as a SELECT column or in WHERE clause.<\/p>\n\n\n\n<p>You can specify the array as a literal using round braces and single quotes ( e.g &#8216;{1, 2, 3}&#8217;), a column name with array data type, or even a subquery whose result is an array.<\/p>\n\n\n\n<p>The above statement will return t\/f for True\/False.<\/p>\n\n\n\n<p>Here is a simple example of ANY statement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">postgres=# SELECT 1 = ANY ('{1,2,3}'::int[]);\n ?column?\n----------\n t\n\npostgres=# SELECT 4 = ANY ('{1,2,3}'::int[]);\n ?column?\n----------\n f<\/pre>\n\n\n\n<p>The above examples use literal arrays. We can also use a column name to provide array values. Here is the SQL query to select only those rows where value 7 is present in array <em>sales<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># select * from employees where 7=ANY(sales);\n id |   name    |     sales\n----+-----------+---------------\n  1 |  John Doe | {9,7,5,4,3,2}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_ALL_Operator\"><\/span>2. Using ALL Operator<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>On the other hand, if you want to check if a value is not present in an array, then you need to use ALL operator. Typically, database programmers end up using != operator to negate the ANY function but it will not work. For example, the following queries will not work.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT 4 != ANY ('{1,2,3}'::int[]);<br>select * from employees where 7 != ANY(sales);<\/pre>\n\n\n\n<p>For this purpose, you will need to use ALL operator. It returns true only if all values in array meet the condition. The following queries will work.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT 4 != ALL('{1,2,3}'::int[]);<br>select * from employees where 7 != ALL(sales);<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_Contains_Operator\"><\/span>3. Using Contains Operator<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In all the above examples using ANY, you can only search for a single value in an array. What if you want to search for multiple values? In such cases, you can <a href=\"https:\/\/www.postgresql.org\/docs\/current\/functions-array.html\" target=\"_blank\" rel=\"noreferrer noopener\">contains operator @&gt;<\/a>. This operator tells if you the first array contains second array. In fact, PostgreSQL provide many operators to compare arrays.<\/p>\n\n\n\n<p>Here is an example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT * FROM mytable WHERE sales @&gt; {7, 5};<\/pre>\n\n\n\n<p>In the above query, PostgreSQL will select only those rows where sales column contains both 7 and 5 values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_Overlap_Operator\"><\/span>4. Using Overlap Operator<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In the above example, PostgreSQL will check if all elements of one array are completely present in the other array. Sometimes you may need to check any of the elements in one array is present in another array. In other words, you may need to check if there is an overlap between two arrays. For such use cases, use the overlap operator &amp;&amp;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT * FROM mytable WHERE sales &amp;&amp; {7, 5};<\/pre>\n\n\n\n<p>In the above query, PostgreSQL will return rows where any of the items 7 and 5 are present in sales column.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>As you can see, PostgreSQL provides some really neat ways to easily work with array columns. Without them, it would have been very tedious to check if an array contains one or more strings. In this article, we have learnt how to check if a single value is present in an array, if one array contains another array, and if there is any overlap between two arrays. You can use any of them as per your requirements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Check_Value_in_Array_Using_Ubiq\"><\/span>Check Value in Array Using Ubiq<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;Reporting tool supports all the above SQL queries and makes it easy to visualize SQL results in different ways. Here is the SQL query mentioned above, in Ubiq. You can also plot SQL query results into charts &amp; dashboards, and share them with others.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"395\" src=\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/image-1.webp?resize=730%2C395&#038;ssl=1\" alt=\"\" class=\"wp-image-8425\"\/><\/figure>\n<\/div>\n\n\n<p>Need a reporting tool for PostgreSQL?&nbsp;<a href=\"http:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data in minutes, and monitor in real-time dashboards.&nbsp;<a href=\"http:\/\/ubiq.co\/accounts\/register\">Try it<\/a>&nbsp;Today!<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-array-in-postgresql\/\">How to Update Array in PostgreSQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-insert-into-array-in-postgresql\/\">How to Insert into PostgreSQL Array<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-array-in-postgresql\/\">How to Create Array in PostgreSQL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.<\/p>\n","protected":false},"author":1,"featured_media":8424,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[348],"tags":[448],"class_list":["post-8422","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql","tag-array-contains"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Check if PostgreSQL Array Contains Value - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Check if PostgreSQL Array Contains Value - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-19T07:39:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-01T05:07:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Check if PostgreSQL Array Contains Value\",\"datePublished\":\"2021-01-19T07:39:00+00:00\",\"dateModified\":\"2025-09-01T05:07:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/\"},\"wordCount\":807,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"array contains\"],\"articleSection\":[\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/\",\"name\":\"How to Check if PostgreSQL Array Contains Value - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2021-01-19T07:39:00+00:00\",\"dateModified\":\"2025-09-01T05:07:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"check value in postgresql array\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-check-if-postgresql-array-contains-value\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Check if PostgreSQL Array Contains Value\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Check if PostgreSQL Array Contains Value - Ubiq BI","description":"Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.","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:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/","og_locale":"en_US","og_type":"article","og_title":"How to Check if PostgreSQL Array Contains Value - Ubiq BI","og_description":"Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2021-01-19T07:39:00+00:00","article_modified_time":"2025-09-01T05:07:36+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Check if PostgreSQL Array Contains Value","datePublished":"2021-01-19T07:39:00+00:00","dateModified":"2025-09-01T05:07:36+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/"},"wordCount":807,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1","keywords":["array contains"],"articleSection":["PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/","name":"How to Check if PostgreSQL Array Contains Value - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1","datePublished":"2021-01-19T07:39:00+00:00","dateModified":"2025-09-01T05:07:36+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to check if value exists in array. Here is how to check if PostgreSQL array contains value.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"check value in postgresql array"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-postgresql-array-contains-value\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Check if PostgreSQL Array Contains Value"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/01\/check-value-in-postgreql-array.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2bQ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8422"}],"version-history":[{"count":3,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8422\/revisions"}],"predecessor-version":[{"id":9385,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8422\/revisions\/9385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8424"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}