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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 problem with the query

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-07-12 : 04:26:43

Hai
In the below query some times there may be no returnId for a purchaseInvoice in such cases the query will not return any result, how can I make this query work with the absence of returnId

select IPIM.purchaseInvoiceId,IPM.purchaseId,IPM.purchaseDate,IPRM.purchaseReturnId,IPRM.purchaseReturnDate from InventoryPurchaseMaster IPM,InventoryPurchaseInvoicePurchaseVoucherIds IPIPVID,InventoryPurchaseInvoicePurchaseReturnIds IPIPRID,InventoryPurchaseInvoiceMaster IPIM, InventoryPurchaseReturnMaster IPRM where IPRM.purchaseReturnId=IPIPRID.purchaseReturnId and IPM.purchaseId=IPIPVID.purchaseVoucherId and IPIPRID.purchaseInvoiceId=IPIM.purchaseInvoiceId and IPIPVID.purchaseInvoiceId=IPIM.purchaseInvoiceId and IPIM.purchaseInvoiceId='8'

Thanks and Regards
Anu Palavila

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-12 : 05:13:13
Try this

SELECT
IPIM.purchaseInvoiceId,
IPM.purchaseId,
IPM.purchaseDate,
IPRM.purchaseReturnId,
IPRM.purchaseReturnDate
FROM
InventoryPurchaseMaster IPM
INNER JOIN InventoryPurchaseInvoicePurchaseVoucherIds IPIPVID
ON IPM.purchaseId = IPIPVID.purchaseVoucherId
INNER JOIN InventoryPurchaseInvoiceMaster IPIM
ON IPIPVID.purchaseInvoiceId = IPIM.purchaseInvoiceId
INNER JOIN InventoryPurchaseInvoicePurchaseReturnIds IPIPRID
ON IPIM.purchaseInvoiceId = IPIPRID.purchaseInvoiceId
LEFT JOIN InventoryPurchaseReturnMaster IPRM
ON IPIPRID.purchaseReturnId = IPRM.purchaseReturnId
WHERE
IPIM.purchaseInvoiceId = '8'



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

Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-07-12 : 06:20:06

Thank you khtan for your valuable answer

Thanks and Regards
Anu Palavila
Go to Top of Page
   

- Advertisement -