brickelldb
Registered User.
- Local time
- Today, 03:22
- Joined
- Mar 9, 2009
- Messages
- 70
It doesnt prompt me for an ItemID. If I attempt to run the query just as you provided, it does not return data, it returns the message "only 1 record can be returned at a time with this subquery". So, in order to return data, I manually hardcoded into the query a criteria for a particular itemID. Because it would not return any data otherwise.
Re: Your question, I would imagine that possible it could occur that 2 vendors contain the same lowest price for a particular ItemID. There are over 20,000 uniqe items. And in the Tbl_PriceCheck, there are 2 to 5 vendors selling that same ItemID with different prices. I would be foolish to say it would never happen...............(could this be the reason for the message "only 1 record can be returned...."?)
Here is an example of what is in the Tbl_PriceCheck (this table contains the various prices from each vendor, for each item):
ID, ItemID, VendorID, Price
--------------------------
1, ab123, 1, 200
2, ab123, 2, 300
3, ab123, 3, 400
4, tv987, 1, 50
5, tv987, 2, 20
6, tv987, 3, 75
7, jk456, 1, 5
8, jk456, 2, 15
9, jk456, 3, 7
So, what I would want the query to return to me is as follows (notice how it returned only the lowest price and it's respective vendor for each ItemID available in the PriceCheck table):
ItemID, VendorID, Price
-----------------------
ab123, 1, 200
tv987, 2, 20
jk456, 1, 5
So that I can turn around and with the above query, update the table called Tbl_PurchaseOrder which already contains the following:
ID, POID, ItemID, VendorID, Price
-------------------------------------
1, 1, abc123, 0, 0
1, 1, tv987, 0, 0
1, 1, jk456, 0, 0
In summary, the Tbl_PriceCheck contains all available Items and their prices from all available vendors who sell those items. The Tbl_PurchaseOrder contains the items we need to order. The user enters the itemID's he wants.......and then I need for the query to update it with the lowest price and the vendorID from which that lowest price is coming from...........ahhhhhhhhhhh I hope I'm explaining myself properly.
Re: Your question, I would imagine that possible it could occur that 2 vendors contain the same lowest price for a particular ItemID. There are over 20,000 uniqe items. And in the Tbl_PriceCheck, there are 2 to 5 vendors selling that same ItemID with different prices. I would be foolish to say it would never happen...............(could this be the reason for the message "only 1 record can be returned...."?)
Here is an example of what is in the Tbl_PriceCheck (this table contains the various prices from each vendor, for each item):
ID, ItemID, VendorID, Price
--------------------------
1, ab123, 1, 200
2, ab123, 2, 300
3, ab123, 3, 400
4, tv987, 1, 50
5, tv987, 2, 20
6, tv987, 3, 75
7, jk456, 1, 5
8, jk456, 2, 15
9, jk456, 3, 7
So, what I would want the query to return to me is as follows (notice how it returned only the lowest price and it's respective vendor for each ItemID available in the PriceCheck table):
ItemID, VendorID, Price
-----------------------
ab123, 1, 200
tv987, 2, 20
jk456, 1, 5
So that I can turn around and with the above query, update the table called Tbl_PurchaseOrder which already contains the following:
ID, POID, ItemID, VendorID, Price
-------------------------------------
1, 1, abc123, 0, 0
1, 1, tv987, 0, 0
1, 1, jk456, 0, 0
In summary, the Tbl_PriceCheck contains all available Items and their prices from all available vendors who sell those items. The Tbl_PurchaseOrder contains the items we need to order. The user enters the itemID's he wants.......and then I need for the query to update it with the lowest price and the vendorID from which that lowest price is coming from...........ahhhhhhhhhhh I hope I'm explaining myself properly.
Last edited: