Thread: SQL logic
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