I have two tables - one for purchases and one for stores. They have mostly similar fields, but not completely.
I wish to list all transactions from the purchase and the stores tables in one grid. The item numbers and dates they have, refer to similar fields.
I have done the following query - which of course does not work :
UserGridData.Query = "Select maintrans.maintransno as mainno, maintrans.itemno as mainitemno, maintrans.date as maindate, maintrans.quantityordered as mainquantityordered, maintrans.quantitydelivered as mainquantitydelivered, maintrans.unitpriceexcl as mainrate, maintrans.centreno as maincentreno, maintrans.supplier as mainsupplier from maintrans UNION select storestrans.storetransno, storetrans.itemno, storestrans.date, storestrans.quantity, storestrans.itemsleft, storestrans.unitpriceexcl, storestrans.centreno, storestrans.supplier from storestrans order by maintrans.date where maintrans.itemno=" & CLng(fgAll.TextMatrix(fgRow, 0))
I think it is mainly my .. where .. and .. order by .. sections that are incorrect. How do I refer to where and order by in the two different tables to see that it only extracts the same item number from both tables and order by the dates given in both tables ?
Thanks
I wish to list all transactions from the purchase and the stores tables in one grid. The item numbers and dates they have, refer to similar fields.
I have done the following query - which of course does not work :
UserGridData.Query = "Select maintrans.maintransno as mainno, maintrans.itemno as mainitemno, maintrans.date as maindate, maintrans.quantityordered as mainquantityordered, maintrans.quantitydelivered as mainquantitydelivered, maintrans.unitpriceexcl as mainrate, maintrans.centreno as maincentreno, maintrans.supplier as mainsupplier from maintrans UNION select storestrans.storetransno, storetrans.itemno, storestrans.date, storestrans.quantity, storestrans.itemsleft, storestrans.unitpriceexcl, storestrans.centreno, storestrans.supplier from storestrans order by maintrans.date where maintrans.itemno=" & CLng(fgAll.TextMatrix(fgRow, 0))
I think it is mainly my .. where .. and .. order by .. sections that are incorrect. How do I refer to where and order by in the two different tables to see that it only extracts the same item number from both tables and order by the dates given in both tables ?
Thanks