Vincent Yip
Vincent Yip

Reputation: 1

how to use SQL query the result

have below 3 tables,how to use SQL query result

Invoice Sales   Client                  
S1908012    Ted ABCD                    
Invoice SKU InvoiceQty                  
S1908012    CD-F002875976   10                  
S1908012    CD-F002784888   20                  
S1908012    CH-126640   30                  
Shelf   SKU Batch   ShelfQty                
01-A01  CD-F002875976   DA2 4               
01-A02  CD-F002875976   DA3 9               
01-B56  CD-F002784888   FEW1    20              
02-A01  CH-126640   ES3 15              
02-A02  CH-126640   ES4 9               

Result

Invoice Sales   Client  SKU InvoiceQty  Shelf   ShelfQty    Batch
S1908012    Ted ABCD    CD-F002875976   10  01-A01  4   DA2
S1908012    Ted ABCD    CD-F002875976   10  01-A02  6   DA3
S1908012    Ted ABCD    CD-F002784888   20  01-B56  20  FEW1
S1908012    Ted ABCD    CH-126640   30  02-A01  15  ES3
S1908012    Ted ABCD    CH-126640   30  02-A02  9   ES4

Excel show these table and result

Upvotes: 0

Views: 45

Answers (1)

Ali Rameez
Ali Rameez

Reputation: 36

Suppose we name your tables as Table1, Table 2 and Table 3, then this will be your query to get the result.

select Table1.*, 
Table2.SKU, Table2.InvoiceQty, 
Table3.Shelf, Table3.ShelfQty, Table3.Batch from Table1 
inner join Table2 on Table1.Invoice = Table2.Invoice
inner join Table3 on Table2.SKU  = Table3.SKU

Upvotes: 1

Related Questions