Thread: FW: Dumping a query result to a table

FW: Dumping a query result to a table

From
"Daniel Malcolm Webb [dbw]"
Date:

Hi all,

 

I’ve been searching for the answer to this question but Google is not playing ball. Basically I have a terrible database adaptor (long story, but basically all I can use at the moment)  for Ruby that doesn’t seem to be compatible with PSQL 8.3, and so I can’t run this query below from it. So best thing to do I thought would be to dump the results of the query to a single table and just query that table. Is this possible? (and yes this query is a mess and is returning too many rows at the moment)

 

SELECT question_stem, option_text, author_id, QR.module_code, correct, weighting, question_option.option_id, feedback  FROM question Q

LEFT JOIN assessment_question_option_stat AQO

                ON AQO.question_id = Q.question_id

LEFT JOIN question_module

                ON question_module.question_id = Q.question_id

LEFT JOIN question_option

                ON question_option.question_id = Q.question_id

LEFT JOIN question_response QR

                ON QR.question_id = Q.question_id

LEFT JOIN question_objective

                ON question_objective.question_id = Q.question_id

LEFT JOIN question_keyword qk

                ON qk.question_id = Q.question_id

 

 

Kind Regards,

Dan Webb

____________________________________________________________

Swyddog Datblygu a Chynnal Systemau Gwybodaeth

Information Systems Development & Support Officer

 

Gwasanaethau Gwybodaeth             Information Services

Prifysgol Aberystwyth               Aberystwyth University

 

E-bost / E-mail: dbw@aber.ac.uk

Ffon / Tel: (01970) 628408

____________________________________________________________

 

Re: FW: Dumping a query result to a table

From
"Sean Davis"
Date:
On Wed, Oct 22, 2008 at 9:56 AM, Daniel Malcolm Webb [dbw]
<dbw@aber.ac.uk> wrote:
> Hi all,
>
>
>
> I've been searching for the answer to this question but Google is not
> playing ball. Basically I have a terrible database adaptor (long story, but
> basically all I can use at the moment)  for Ruby that doesn't seem to be
> compatible with PSQL 8.3, and so I can't run this query below from it. So
> best thing to do I thought would be to dump the results of the query to a
> single table and just query that table. Is this possible? (and yes this
> query is a mess and is returning too many rows at the moment)

create table newtable as ....

> SELECT question_stem, option_text, author_id, QR.module_code, correct,
> weighting, question_option.option_id, feedback  FROM question Q
>
> LEFT JOIN assessment_question_option_stat AQO
>
>                 ON AQO.question_id = Q.question_id
>
> LEFT JOIN question_module
>
>                 ON question_module.question_id = Q.question_id
>
> LEFT JOIN question_option
>
>                 ON question_option.question_id = Q.question_id
>
> LEFT JOIN question_response QR
>
>                 ON QR.question_id = Q.question_id
>
> LEFT JOIN question_objective
>
>                 ON question_objective.question_id = Q.question_id
>
> LEFT JOIN question_keyword qk
>
>                 ON qk.question_id = Q.question_id
>
>
>
>
>
> Kind Regards,
>
> Dan Webb
>
> ____________________________________________________________
>
> Swyddog Datblygu a Chynnal Systemau Gwybodaeth
>
> Information Systems Development & Support Officer
>
>
>
> Gwasanaethau Gwybodaeth             Information Services
>
> Prifysgol Aberystwyth               Aberystwyth University
>
>
>
> E-bost / E-mail: dbw@aber.ac.uk
>
> Ffon / Tel: (01970) 628408
>
> ____________________________________________________________
>
>

Re: FW: Dumping a query result to a table

From
"Daniel Malcolm Webb [dbw]"
Date:
Thank you I could possibly kiss you. 

Thanks,
Dan


-----Original Message-----
From: seandavi@gmail.com [mailto:seandavi@gmail.com] On Behalf Of Sean Davis
Sent: 22 October 2008 15:05
To: Daniel Malcolm Webb [dbw]
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] FW: Dumping a query result to a table

On Wed, Oct 22, 2008 at 9:56 AM, Daniel Malcolm Webb [dbw]
<dbw@aber.ac.uk> wrote:
> Hi all,
>
>
>
> I've been searching for the answer to this question but Google is not
> playing ball. Basically I have a terrible database adaptor (long story, but
> basically all I can use at the moment)  for Ruby that doesn't seem to be
> compatible with PSQL 8.3, and so I can't run this query below from it. So
> best thing to do I thought would be to dump the results of the query to a
> single table and just query that table. Is this possible? (and yes this
> query is a mess and is returning too many rows at the moment)

create table newtable as ....

> SELECT question_stem, option_text, author_id, QR.module_code, correct,
> weighting, question_option.option_id, feedback  FROM question Q
>
> LEFT JOIN assessment_question_option_stat AQO
>
>                 ON AQO.question_id = Q.question_id
>
> LEFT JOIN question_module
>
>                 ON question_module.question_id = Q.question_id
>
> LEFT JOIN question_option
>
>                 ON question_option.question_id = Q.question_id
>
> LEFT JOIN question_response QR
>
>                 ON QR.question_id = Q.question_id
>
> LEFT JOIN question_objective
>
>                 ON question_objective.question_id = Q.question_id
>
> LEFT JOIN question_keyword qk
>
>                 ON qk.question_id = Q.question_id
>
>
>
>
>
> Kind Regards,
>
> Dan Webb
>
> ____________________________________________________________
>
> Swyddog Datblygu a Chynnal Systemau Gwybodaeth
>
> Information Systems Development & Support Officer
>
>
>
> Gwasanaethau Gwybodaeth             Information Services
>
> Prifysgol Aberystwyth               Aberystwyth University
>
>
>
> E-bost / E-mail: dbw@aber.ac.uk
>
> Ffon / Tel: (01970) 628408
>
> ____________________________________________________________
>
>