Skip site navigation (1) Skip section navigation (2)

SQL Question

From: Daryl Herzmann <akrherz(at)iastate(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: SQL Question
Date: 2000-08-01 20:38:13
Message-ID: (view raw or flat)
Lists: pgsql-sql
	I hope this question is not too novice for this group.

I have a table

portfolio=# \d questions
                               Table "questions"
 Attribute |    Type     |                      Modifier                       
 qid       | integer     | not null default nextval('questions_qid_seq'::text)
 optiona   | text        | default 'Z'
 optionb   | text        | default 'Z'
 optionc   | text        | default 'Z'
 optiond   | text        | default 'Z'
 optione   | text        | default 'Z'
 optionf   | text        | default 'Z'
 optiong   | text        | default 'Z'
 optionh   | text        | default 'Z'

and other table named quizes, which contains references to the
questions. Basically a quiz is composed of up to three questions.

portfolio=# \d quizes
                                 Table "quizes"
 Attribute |    Type     |                       Modifier                       
 quiznum   | integer     | not null default nextval('quizes_quiznum_seq'::text)
 question1 | integer     | 
 question2 | integer     | 
 question3 | integer     | 

So my question is if I want to querry out a particular quiz and all its
questions and question options, how can I do that in one command. I know
that I could do it with a couple of loops, but I think the SQL is much
more eliquent.  Maybe I have my tables incorrectly set up?  And

Thanks all,

pgsql-sql by date

Next:From: Gerhard DieringerDate: 2000-08-02 07:32:40
Subject: Antw: SQL Question
Previous:From: Michael RichardsDate: 2000-08-01 18:32:27
Subject: Re: on line numbers, drop table errors, and log files

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group