From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | Michael Thorsen <mthorsen1980(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SQL query |
Date: | 2008-11-22 15:47:08 |
Message-ID: | 4928297C.1070805@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 22/11/2008 04:33, Michael Thorsen wrote:
> select count(*)
> from user_table u, locations l
> where u.user_code = l.code
> and u.price = l.price
> and u.value = l.value;
>
> The answer to this should be 2, but when I run my query I get 4 (in fact
Are you sure that's the query that's being run? I just tried it here,
and got 2 - this was using your data above.
What do your table definitions look like? - here's what I did:
CREATE TABLE user_table
(
user_id integer NOT NULL,
user_code integer NOT NULL,
price numeric(6,2) NOT NULL,
"value" numeric(6,2) NOT NULL,
CONSTRAINT user_pk PRIMARY KEY (user_id)
)
WITH (OIDS=FALSE);
CREATE TABLE locations
(
id integer NOT NULL,
code integer NOT NULL,
price numeric(6,2) NOT NULL,
"value" numeric(6,2) NOT NULL,
CONSTRAINT location_pk PRIMARY KEY (id)
)
WITH (OIDS=FALSE);
Does this correspond to what you have?
Ray.
------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2008-11-22 16:23:31 | Re: SQL query |
Previous Message | Ciprian Dorin Craciun | 2008-11-22 15:40:27 | Fwd: Using Postgres to store high volume streams of sensor readings |