Re: SQL Query gone wrong.. please help

From: Murat Tasan <murat(dot)tasan(at)cwru(dot)edu>
To: Srinivas Iyyer <srini_iyyer_bio(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL Query gone wrong.. please help
Date: 2006-02-09 19:00:04
Message-ID: 4B448690-E20F-4B2B-85F8-D7E9B2C3A885@cwru.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On 9 Feb 2006, at 12:50, Srinivas Iyyer wrote:

> Hi,
> thank you for correcting me. I agree, I am very weak
> in connecting tables, I did not digest the connecting
> logic, although based on my progra. experience i am
> able to write plpgsql functions etc not relating to
> sql query part.
> I am trying to learn from Bruce momjian's book.
>
> I have one more question, hope that is not problem for
> you to help me out again.
>
> How do I put another conditional that gos.go_cat = 'F'
> only.
>
> In the corrected query, I am getting all gos.go_term
> but I want only if gos.go_cat is 'F'.
>
>
> My version:
>
> select seq_name , go_term,go_cat from sequence, gos,
> go_seq where
> sequence.seq_name = 'EI24' AND
> gos.go_cat = 'F'AND
> sequence.seq_id = go_seq.seq_id AND
> go_seq.gos_id = gos.go_id AND
> gos.gos_id = gos.go_cat;
>

remove that last line "gos.gos_id = gos.go_cat". you've already done
the appropriate selection with "gos.go_cat = 'F'".

as you have it written now, i would suspect you are getting zero
results, because it's doubtful that the gos_id will ever equal the
go_cat.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Luiz K. Matsumura 2006-02-09 20:25:41 Autovacuum log messages
Previous Message Srinivas Iyyer 2006-02-09 17:50:31 Re: SQL Query gone wrong.. please help