Neophyte: sub-select returning multpile rows
Keeping in mind that I'm still quite the Oracle neophyte, I'm having the following problem with a
select, sub-select query.
First let me layout the 2 tables involved.
Code:
Table 1 : t215
Column1 : C1
Column2 : C7
C1 C7
---------------- ------
John 0
Anne 3
Table 2 : FIELD_ENUM_VALUES
Column1 : SCHEMAID
Column2 : FIELDID
Column3 : ENUMID
Column4 : VALUE
SCHEMAID FIELDID ENUMID VALUE
---------- ------------ ---------- --------------------
215 7 0 Active
215 7 1 Expired
215 7 2 Sponser Emailed
What I need to do is return the data from field_enum_values.value for each single row in t215
For example:
(select statement here)
Code:
c1 field_enum_value.value
--------- ------------------------
John Active
Anne Sponser Emailed
Instead I'm getting:
Code:
c1 field_enum_value.value
--------- ------------------------
John Active
John Sponser Emailed
Anne Active
Anne Sponser Emailed
I thought the following would work, but I have since found out that it doesn't
Code:
SELECT a.c1,
b.curr_status
FROM T215 a,
(SELECT enumval.value curr_status FROM FIELD_ENUM_VALUES enumval, T215 status
WHERE enumval.schemaid = 215
AND enumval.fieldid = 7
AND enumval.enumid = status.c7) b
I think I understand that the subselect will return all the rows (which it is doing),
but I'm not able to currently comprehend how to make it only return one value for each row in t215.
I hope that this issue is clear.
Thank you in advance.
Mark Nelson