From: Raymond O'Donnell <rod@iol.ie>
To: Michael Thorsen <mthorsen1980@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: SQL query
Date: Sat, 22 Nov 2008 15:47:08 +0000
Message-ID: <4928297C.1070805@iol.ie> (raw)
In-Reply-To: <4c8d33a90811212033x5e88177eo7a026b10336c975b@mail.gmail.com>
References: <4c8d33a90811212033x5e88177eo7a026b10336c975b@mail.gmail.com>
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@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rod@iol.ie, mthorsen1980@gmail.com
Subject: Re: SQL query
In-Reply-To: <4928297C.1070805@iol.ie>
References: <4c8d33a90811212033x5e88177eo7a026b10336c975b@mail.gmail.com> <4928297C.1070805@iol.ie>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox