The UNION Clause is used to combine the output of two SQL Queries. But beware, using UNION will remove duplicate rows from the output. If you need to have all the rows from both the queries, use UNION ALL clause.
Example:
(SELECT A.CardNo as EntryCode, A.CardNo as BillNo, A.CardDate As BillDate,C.CustomerName As Details, ' ' As Inward, B.Quantity As Outward, 'OnCard' as TransType FROM OnCard as A, OnCardDetails As B, MasterCustomers as C WHERE A.CardNo=B.CardNo AND A.CustomerCode=C.CustomerCode AND B.ProductCode=28935)
UNION ALL
(SELECT A.BillNo as EntryCode, A.BillNo, A.BillDate, A.CustomerName As Details, ' ' As Inward, B.Quantity As Outward, 'Sale' as TransType FROM BillSale As A, BillSaleDetails as B WHERE A.BillNo=B.BillNo AND B.ProductCode=28935 )
No comments:
Post a Comment