I will explain everything in detail:
The database contains 4 tables
1- tbl_order (OrderID PK , OrderNo, Employee_ID, Customer_ID, OrderDate)
2- tbl_Orderdetails( OrderDetailID, OrderID FK, ProductID, Quantity , Date Required, UnitPrice)
3- tbl_Production (BatchNo, Employee_ID, DateEntered)
4- tbl_ProductionDetail ( BatchNO, Date, Machine_ID, Employee_ID, Product_ID, Quantity, Defective, OvertimeQuantity, OvertimeDefective)
in the second table (tbl_Orderdetails) I made the field orderdetailID as PK in order to allow duplicating the product
because the order will be like that:
Product Product quantity daterequired
So I can have the same product more than one time but the daterequired will be different.
Assume that I have this order
Expand|Select|Wrap|Line Numbers
- Product Quantity Date Required
- T.V 10 1/6/2010
- T.V 3 1/8/2010
- VCR 17 1/15/2010
- Camera 4 1/14/2010
and the production department will receive the same order to carry it out
and the will enter units produced into the database like that:
Expand|Select|Wrap|Line Numbers
- Product Quantity Date
- T.V 2 1/7/2010
- VCR 6 1/2/2010
- Camera 1 1/10/2010
- TV 2 1/4/2010
- Camera 2 1/5/2010
in other words i want to compare between the production and orders depending on the order date required of every product, it's now 8 days looking for any piece of information to make this query