Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with EXISTS clause with subquery

Status
Not open for further replies.

asplus

Instructor
Oct 11, 2002
16
0
0
Please see the following SQL:

SELECT CASE WHEN EXISTS (select * from cohead, aropen where cohead_type = 'C' and aropen_ordernumber = cohead_number and aropen_doctype = 'I') THEN 'R'
ELSE 'N'
END AS type
FROM aropen
WHERE ( (aropen_cust_id=<? value("cust_id") ?>)
AND (aropen_open)
AND ((aropen_amount - aropen_paid) > 0) )
ORDER BY aropen_docdate;



I get 'R' in type all the time. I should get some 'N' and 'R' results, not all 'R's.



Thanks,



--
Bernard Le Jour
AS Plus Informatique Inc.
 
Hi

Due to your style of not prefixing field names with table names, is hard to understand what is written there. But to me seems there is no relation between the inner [tt]select[/tt] and the outer one. So the inner [tt]select[/tt] would return the same complete tuple list every time.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top