'Anneal' <> 'Anneal'

From: "Rob Richardson" <Rob(dot)Richardson(at)rad-con(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: 'Anneal' <> 'Anneal'
Date: 2010-04-05 20:38:03
Message-ID: 04A6DB42D2BA534FAC77B90562A6A03D012F529E@server.rad-con.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings!

I have the following query:

select charge.charge, alarm_history.area || '!', bases.area || '!',
alarm_history.area::character varying(32) = bases.area::character
varying(32), alarm_history.area <> bases.area, alarm_history.*
from charge
JOIN bases ON charge.base::text = bases.base::text
inner join alarm_history
on charge.charge = alarm_history.charge
or
(
alarm_history.alarm_date > charge.fire_date
and
(
alarm_history.alarm_date < charge.cold_date
or charge.cold_date is null
)
and device = 'Global')
where charge.charge = 64489

This query returns 9 records. For all of them, alarm_history.area is
'Anneal' and bases.area is 'Anneal'. Yet, the column for the equality
test is always "f" and the column for the inequality test is always "t"!


The alarm_history table definition begins with:

CREATE TABLE alarm_history
(
alarm_pkey bigserial NOT NULL,
area character varying(32), -- shop area

and the bases table definition has:

CREATE TABLE bases
(
area character varying(32) NOT NULL DEFAULT 'All'::character varying,

I have no idea why these two look to be different. I've tried appending
an exclamation point to both of them to check for extra spaces at the
end. There aren't any. I've tried casting them both to text and to
character varying(32), but I got the same results.

I'm running PostgreSQL 8.4 on WinXP Pro. I get the same results on a
customer's machine running a 64-bit Windows OS, using an identical
database.

Can anyone explain this, please?


RobR

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Richardson 2010-04-05 20:59:47 Re: 'Anneal' <> 'Anneal'
Previous Message David Kerr 2010-04-05 20:36:00 Re: Connection Pooling