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

From Chuck Roberts
Subject Re: [NOVICE] Trouble with IN operator
Date
Msg-id CAByBP0pUZJ74SprJv_jPWwUCb6EwfH0O0sVkSGH3U5R+-fdCZg@mail.gmail.com
Whole thread Raw
In response to Re: [NOVICE] Trouble with IN operator  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [NOVICE] Trouble with IN operator
List pgsql-novice
Yes there is data that matches the criteria of the IN condition. When I remove the clause with the IN, I get all kinds of records that look like they match the criteria. The tbl.costcenter is a string of 3 characters, but it only contains numbers which are zero padded, like '001', '540', '900'. There should be no room for odd characters, even though users do enter this number. 

Also I tried a case-insensitive regex, and that didn't work either. Ex: 
AND (tbl.costcenter ~* '(540|001|900)')



Thanks!


On Fri, Feb 3, 2017 at 1:40 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Chuck Roberts <croberts@gilsongraphics.com> writes:
> I think this might be a data problem. If anyone else has an idea, it's
> welcome.

Well, the obvious question is, are you sure you have records that *should*
match the condition?

Plain "trim" is not very bright, it will only remove characters that are
plain ASCII spaces.  I'm wondering a bit about whether there's carriage
returns, tabs, non-breaking spaces, or other weird kinds of whitespace in
your data, which might make it so records that look like they contain
"540" don't actually match.

                        regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: [NOVICE] Trouble with IN operator
Next
From: "David G. Johnston"
Date:
Subject: Re: [NOVICE] Trouble with IN operator