How can I select rows by comparing an array data type column with multiple values ?

From: Arup Rakshit <aruprakshit(at)rocketmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: How can I select rows by comparing an array data type column with multiple values ?
Date: 2014-06-02 10:54:58
Message-ID: 1401706498.38103.YahooMailNeo@web193902.mail.sg3.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Suppose, I have a table as below :-

id |    title     |    content     |       tags
----+--------------+----------------+-------------------
  1 | sample post  | lorem ipsum    | {apple,orange}
  2 | another post | fruits are bad | {apple,hamburger}
  3 | third post   | foo bar            | { banana, lemon }
  4 | third post   | foo baz           | { watermelon, lemon }

Now I want to select all rows, for which tags will having either one or all value from the this array [apple,banana] ? how should I write the query using such a set ?

output should select 1,2,3.
 
Regards,
Arup Rakshit

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2014-06-02 11:21:31 Re: How can I select rows by comparing an array data type column with multiple values ?
Previous Message Rajeev rastogi 2014-06-02 05:03:08 Re: How is sorting work?