[NOVICE] Trouble with IN operator - Mailing list pgsql-novice

From Chuck Roberts
Subject [NOVICE] Trouble with IN operator
Date
Msg-id CAByBP0oSftfkNWtAu5gRVUH5CFXKGTu5TKtM87BvL5eM5Z9cAw@mail.gmail.com
Whole thread Raw
Responses Re: [NOVICE] Trouble with IN operator
Re: [NOVICE] Trouble with IN operator
List pgsql-novice

I'm having trouble with the IN operator when querying a Postgresql db using
the psql command line tool. Now that I think of it, I've never gotten the
IN operator to work before. And now it's critical. I'm using the psql tool
in a Windows 7 command window, version is 7.4.6.

I wonder if I'm missing something basic, which is not even in the manuals
I've been reading. I want to find a string field in an array of strings. I
want to limit the costcenter I'm selecting on and the costcenter is a
string. I've already googled to find some help but have found no info or
examples on using IN with an array of strings. So here's what I'm trying to
do:

AND (TRIM(tbl.costcenter)  IN ('540'))

This results on no error, but also no records. When I take this simple
clause out, I get records. I've also tried using regex, and get the same
result: no records are returned.

AND ((tbl.costcenter ~* '^(540|001)$')  )

Can anyone shed some light on this for me?

Thank you.



pgsql-novice by date:

Previous
From: padmini
Date:
Subject: Re: [NOVICE] Postgres authentication to multiple application servers
Next
From: "David G. Johnston"
Date:
Subject: Re: [NOVICE] Trouble with IN operator