I want to inner join with a child table based on ID and get the top Row of the child table,
I am not joining to take any data out of the child table, its just to validate that child table record exists for parent table.
If I dont include TOP row there is chances of getting multiple rows of parent in the result set.
— Chances of multiple rows in resultset for same PARENTID is possible
SELECT P.PARENTID FROM PARENT P
INNER JOIN CHILD C ON C.PARENTID =
P.PARENTID and C.ISACTIVE = 1
I need something like
SELECT P.PARENTID FROM PARENT P
INNER JOIN (SELECT TOP 1 * FROM CHILD ) AS C
ON C.PARENTID = P.PARENTID
AND C.ISACTIVE = 1
I not sure how to get it working
I am curious if somebody can help me out or provide me any url where I could find the solution
Do you think WHERE EXISTS will do the job ?