pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: onin <jnana@mobius.ph>
To: pgsql-sql@postgresql.org
Subject: table joining duplicate records
Date: Sat, 08 Jul 2006 17:02:04 +0800
Message-ID: <44AF748C.2010100@mobius.ph> (raw)

hi all,

somebody please help me with my sql statement.
or point me to the right documentation that i need to read.

what i want to working on right now is to create a db for a survey app
my tables look this

surveys
survey_id:survey
----------------
1        : survey1

categories
category_id:category
----------------
1        :category1

questions
question_id:question
----------------
1        :question1

answers
answer_id:answer
----------------
1        :answer1
2        :answer2

questions_answers
question_answer_id:survey_id:category_id:question_id:answer_id
1                 :1                    :1          :1
1                 :1                    :1          :2

and my query looks like this

select s.survey, c.category, q.question, a.answer from questions_answers 
qa, answers a, questions q, categories c, surveys s
where qa.answer_id = a.answer_id and qa.question_id = q.question_id and 
qa.category_id = c.category_id and qa.survey_id = s.survey_id;


after executing the code,
i get results like this.

--query results--
survey :category :question :answer
survey1:category1:question1:answer1
survey1:category1:question1:answer2

how can i elimate duplicates on my query results?
an also am i using the right 'table joining' or table design for my 
survey app?


any help would be appriciated.
thanks in advance.

-- 
"A whim, a thought, and more is sought... awake, my mind... thy will be wrought!"





view thread (4+ messages)  latest in thread

Message-ID: <44AF748C.2010100@mobius.ph>
Permalink:  ../44AF748C.2010100@mobius.ph/
Also on:    postgresql.org/message-id/44AF748C.2010100@mobius.ph

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jnana@mobius.ph
  Subject: Re: table joining duplicate records
  In-Reply-To: <44AF748C.2010100@mobius.ph>

* 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