X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4AD1C475A80 for ; Tue, 15 Apr 2003 06:33:35 -0400 (EDT) Received: from fish.net (codepoets.co.uk [81.5.147.148]) by postgresql.org (Postfix) with ESMTP id 440E0474E44 for ; Tue, 15 Apr 2003 06:33:34 -0400 (EDT) Received: by fish.net (Postfix, from userid 612) id 9525F1E07; Tue, 15 Apr 2003 11:33:31 +0100 (BST) Received: from haddock.fish.net (haddock.fish.net [192.168.0.2]) by fish.net (Postfix) with ESMTP id DA77D1B2E for ; Tue, 15 Apr 2003 11:33:29 +0100 (BST) Received: by haddock.fish.net (Postfix, from userid 1000) id CBD72ECAB; Tue, 15 Apr 2003 11:33:29 +0100 (BST) Date: Tue, 15 Apr 2003 11:33:29 +0100 From: David Goodwin To: pgsql-sql@postgresql.org Subject: ordering problems ... Message-ID: <20030415103328.GA3076@codepoets.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Operating-System: Slackware Linux 8.1 + - 2.4.20-ck6 X-Spam-Status: No, hits=-12.7 required=5.0 tests=BAYES_10,SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/223 X-Sequence-Number: 12924 Hello everyone, I have two tables : question_response and question_response_answer. There is a one to many relationship between the question_response and a question_response_answer (schema below at the bottom). When I execute : select answer from question_response_answer qra, question_response qr WHERE qr.response_id = qra.response_id AND qr.personal_id = 'XXYYTEST2' AND qr.module_code = 'TEST990' AND qr.assessment_id = 109 AND qr.question_id = 125 ; I get : answer --------- Foo Bar Fred No Yes When I execute : select * from question_response_answer; I get : response_id | answer -------------+------------ 148 | Yes 148 | No 148 | Fred 148 | Foo Bar I'd like to know why the ordering has changed, and is there anything I can do make it the same as it is on the "select * from question_response_answer" "version" ? Running Postgres 7.3.2 on Linux. Schema : Column | Type | Modifiers ---------------+----------------------+-------------------------------------------------------- response_id | integer | not null default nextval('question_reponse_seq'::text) question_id | integer | personal_id | character varying(9) | assessment_id | integer | module_code | character varying(9) | Indexes: question_response_pkey primary key btree (response_id), question_response_question_id_key unique btree (question_id, personal_id, assessment_id) (there are foreign keys, but I've left them off) tweektest=> \d question_response_answer; Table "public.question_response_answer" Column | Type | Modifiers -------------+---------+----------- response_id | integer | not null answer | text | not null Indexes: question_response_answer_pkey primary key btree (response_id, answer) Foreign Key constraints: $1 FOREIGN KEY (response_id) REFERENCES question_response(response_id) ON UPDATE NO ACTION ON DELETE CASCADE Thanks in advance, David. -- David Goodwin [ dof at codepoets dot co dot uk ] [ http://www.codepoets.co.uk ]