Re: Select a.x ,b from (select x) a, b question. [message #373682] |
Tue, 01 May 2001 14:47 |
Andrew again...
Messages: 270 Registered: July 2000
|
Senior Member |
|
|
No, for a correlated subquery you need to have something similar to this form:
SELECT e.name, b1.no_insurance
FROM emp e, b b1
where (b1.id, b1.insurance_no) in
(SELECT b2.id, b2.no_insurance
FROM b b2
WHERE b2.id = emp.id
AND ROWNUM = 1)
Be careful about your "rownum = 1" this raises concerns that there is some missing logic. That condition will not consistently return the same sesult as there is no logic to distinguish between duplicates. Consider adding a further condition to select max(b1.id) or include some other condition to restrict to one row in the sub query.
|
|
|
|