Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Join Multiple Table

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2009-08-01 : 02:56:51
Dear All,

I tried following two queary from multiple table,

First Queary:
select o.DocNum,r1.DocEntry,r1.ItemCode,i1.Father,i1.Code from ORDR As o
Left Join RDR1 As r1
On r1.DocEntry = o.DocNum
Left Join ITT1 As i1
On i1.Father = r1.ItemCode
where o.DocNum = '49' and r1.ItemCode = 'JDET01'

OutPut:

49 49 JDET01 JDET01 JD08
49 49 JDET01 JDET01 JD09
49 49 JDET01 JDET01 JD10
49 49 JDET01 JDET01 JD12
49 49 JDET01 JDET01 JD13
49 49 JDET01 JDET01 JD05
49 49 JDET01 JDET01 JD15

Second Queary:
select ot.Code,i1.Code,om.ItemName From OITT As ot
Left Join ITT1 As i1
On i1.Father = ot.Code
Left Join OITM As om
On om.ItemCode = i1.Code
where ot.Code = 'JD08'

OutPut:

JD08 JD81 Sugar
JD08 JD87 Wheat atta

Now i want Following Output,

49 JD81 Sugar
49 JD87 Wheat atta

Means i want ItemName on the basis of DocNum which in first queary.
Means i want this output only on DocNum parameter.
Can anybody tell me how to solve this ?

Thanks and Regards
Harish Patil

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-01 : 06:34:04
it will be easier if you could give us the sample data from each of the table rather than the undesired result of a query.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -