Joining 2 select statements and 2 databases

Leongy

New member
Joined
Mar 24, 2005
Messages
1
Programming Experience
Beginner
hello.. i would be greatly grateful if anyone could help me with this.. i have these 2 lines of code with different criterias for different databases under the same function.. can someone teach me how to join them?



Public Function CheckMyQuantity() As DataSet
Dim sqlString As String

Dim adapter As OleDbDataAdapter

Dim leongy As DataSet

'these 2 lines
sqlString = "SELECT StockID,StockName,Quantity from Branch2Stock WHERE Quantity > 100"
sqlString = "SELECT StockID,StockName,Quantity from BranchStock WHERE Quantity < 20"




adapter = New OleDbDataAdapter(sqlString, cn)

leongy =
New DataSet

adapter.Fill(leongy)

cn.Close()

Return leongy

End Function

 
Ive assumed that the stockid in each table corresponds to the same stock item

SELECT Branch2Stock.StockID AS Branch2Stock_StockID, Branch2Stock.StockName AS Branch2Stock_StockName, Branch2Stock.Quantity AS Branch2Stock_Quantity, BranchStock.StockID AS BranchStock_StockID, BranchStock.StockName AS BranchStock_StockName, BranchStock.Quantity AS BranchStock_Quantity
FROM Branch2Stock INNER JOIN BranchStock ON Branch2Stock.StockID = BranchStock.StockID
WHERE (((Branch2Stock.Quantity)>100) AND ((BranchStock.Quantity)<20));
 
Back
Top