August 12, 2006 at 1:06 am
I have two table one as parent and second as child , i need to write a single query to get all records of parent table and their respective childs
e.g.
TableA
Id ParentName
-------------
1 abc
2 def
3 ghi
TableB
ParentId ChildName
--------------------
1 aa
1 bb
2 cc
Result should be like
Id ParentName ChildName
--------------------------------------
1 abc Null
2 def Null
3 ghi Null
1 abc aa
1 abc bb
2 abc cc
any help will be appreciated
August 12, 2006 at 5:47 pm
Does in only have to be 1 level deep?
SELECT TableA.ID,TableA.ParentId,TableB.ChildName
from TableA Parents
LEFT join TableB Childs
on parents.id=childs.parentid
order by parentname,childname
(still needs some testing)
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply