SQL logic

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SQL logic
Date: 2002-02-01 15:22:21
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB0452DE30@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Howdy:

I need help with SQL logic. I'm trying to match
one field (the sequential number I created) from a
table where the number matches the row it's
assigned to.

For example:

[table 1]

database=> \d bp_disease
Table "bp_disease"
Attribute | Type | Modifier
---------------+-------------------+----------
bp_disease_id | integer |
bp_dis_label | character varying |

database=> select * from bp_disease limit 1;
bp_disease_id | bp_dis_label
---------------+--------------
1 | Asthma

[/table 1]

[table 2]

database=> \d sys_disease
Table "sys_disease"
Attribute | Type | Modifier
-----------+-------------------+--------------------------------------------
--------------
disease | character(2) |
dtype | character(1) |
dlabel | character varying |
dorder | integer | not null default
nextval('sys_disease_dorder_seq'::text)

database=> select * from sys_disease limit 1;
disease | dtype | dlabel | dorder
---------+-------+--------+--------
AS | D | Asthma | 1

[/table 2]

My end goal is to select 'bp_disease_id' from the first table
where it matches the column 'disease'. The only thing that
they have in common is the 'dorder' column.

How would I write that in SQL?

Thanks!

-X

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2002-02-01 15:42:24 Re: Function to Pivot data
Previous Message Tom Lane 2002-02-01 14:45:39 Re: timestamp weirdness