Re: How to select rows for which column has empty array ?

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to select rows for which column has empty array ?
Date: 2014-06-06 16:12:32
Message-ID: 5391E870.6000004@boscorama.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/06/14 07:30, Arup Rakshit wrote:
>
> How would I select rows which has empty array for the field "team_ids" ?

The shortest way is to test against an empty array constant:
select id from reporting_groups where team_ids = '{}';

Or you can test using array_length(). Or you test against an empty
array[], cast appropriately.

HTH,
Bosco.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Keith Fiske 2014-06-06 17:13:44 Trigger function permissions
Previous Message hubert depesz lubaczewski 2014-06-06 16:05:52 Problem with locales on Linux with 9.3.4