Board index » delphi » Locating Master Records based on Detail Values

Locating Master Records based on Detail Values

Trying to obtain a list of master records by querying the contents of
a detail table. The following is close, I think, but I get ' Single
row subquery produced more than one row'. Any help?

SELECT * FROM customer
WHERE CustID =
(SELECT DISTINCT CustID
FROM order o
WHERE o.'Order Code' = :IDOrder)

Thanks
Gregg Snyder
Prestress Services
please remove leading 'x' in email address
--
Gregg Snyder
Prestress Services, Inc.

Remove leading 'x' in header to email
Email Name: prestress
Email Domain: ssi.parlorcity.com

 

Re:Locating Master Records based on Detail Values


Here is a snippet from my code that does what you want:

SELECT DISTINCT DailyTimeSheetHeader.ID
FROM DailyTimeSheetHeader
WHERE (((DailyTimeSheetHeader.ID) In (SELECT
DailyTimeSheetDetail.Header_ID FROM DailyTimeSheetDetail WHERE Project_ID

Quote
> 0)));
Gregg Snyder wrote:
> Trying to obtain a list of master records by querying the contents of
> a detail table. The following is close, I think, but I get ' Single
> row subquery produced more than one row'. Any help?

> SELECT * FROM customer
> WHERE CustID =
> (SELECT DISTINCT CustID
> FROM order o
> WHERE o.'Order Code' = :IDOrder)

> Thanks
> Gregg Snyder
> Prestress Services
> please remove leading 'x' in email address
> --
> Gregg Snyder
> Prestress Services, Inc.

> Remove leading 'x' in header to email
> Email Name: prestress
> Email Domain: ssi.parlorcity.com

Other Threads