I have been looking around and trying to search but no luck on this.. I will continue to do so but would appreciate some help or being pointed to the right direction!
I have 2 datatables (similar to below)
sales_quotes
myIDX inStock QDate MFGname MFGNumber Vendor
+-----+-----+----------+--------+--------+----------+
| 1 | 20 | 3/4/2018 | Burton | snow1 | Christie |
+-----+-----+----------+--------+--------+----------+
| 2 | 100 | 3/8/2018 | Burton | snow1 | Christie |
+-----+-----+----------+--------+--------+----------+
| 3 | 35 | 3/8/2018 | Jones | proto1 | Christie |
+-----+-----+----------+--------+--------+----------+
| 4 | 45 | 3/4/2018 | Jones | proto1 | Christie |
+-----+-----+----------+--------+--------+----------+
sales_quotes_prices
myIDX myQTY myPrice
+-----+------+-------+
| 1 | 20 | 250 |
+-----+------+-------+
| 1 | 50 | 225 |
+-----+------+-------+
| 2 | 20 | 250 |
+-----+------+-------+
| 2 | 50 | 225 |
+-----+------+-------+
| 3 | 20 | 350 |
+-----+------+-------+
| 4 | 10 | 300 |
+-----+------+-------+
| 4 | 50 | 250 |
+-----+------+-------+
I have been able to use inner join to get sales_quotes broken out into multiple lines featuring every qty and price available for them.
SELECT q.myIDX
, q.MFG
, q.MFGN
, q.Vendor
, q.QDate
, q.InStock
, p.myQTY
, p.myPrice
FROM sales_quotes_prices p
JOIN sales_quotes q
ON p.myIDX = q.myIDX
result of join is below
+-------+---------+----------+---------+-----------+----------+-------+---------+
| myIDX | inStock | Qdate | MFGname | MFGNumber | Vendor | myQTY | myPrice |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 1 | 20 | 3/4/2018 | Burton | snow1 | Christie | 20 | 250 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 1 | 20 | 3/4/2018 | Burton | snow1 | Christie | 50 | 225 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 2 | 100 | 3/8/2018 | Burton | snow1 | Christie | 20 | 250 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 2 | 100 | 3/8/2018 | Burton | snow1 | Christie | 50 | 225 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 3 | 35 | 3/8/2018 | Jones | proto1 | Christie | 20 | 350 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 4 | 45 | 3/4/2018 | Jones | proto1 | Christie | 10 | 300 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 4 | 45 | 3/4/2018 | Jones | proto1 | Christie | 50 | 250 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
Goal: I am trying to replace the 'instock' decimal value from the latest 'QDate' on all matching quotes with the same [mfgname, mfgnumber, vendor]
But I am stuck on how to achieve this (below has the 'instock' appropriately allocated!)
+-------+---------+----------+---------+-----------+----------+-------+---------+
| myIDX | inStock | Qdate | MFGname | MFGNumber | Vendor | myQTY | myPrice |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 1 | 100 | 3/4/2018 | Burton | snow1 | Christie | 20 | 250 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 1 | 100 | 3/4/2018 | Burton | snow1 | Christie | 50 | 225 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 2 | 100 | 3/8/2018 | Burton | snow1 | Christie | 20 | 250 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 2 | 100 | 3/8/2018 | Burton | snow1 | Christie | 50 | 225 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 3 | 35 | 3/8/2018 | Jones | proto1 | Christie | 20 | 350 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 4 | 35 | 3/4/2018 | Jones | proto1 | Christie | 10 | 300 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
| 4 | 35 | 3/4/2018 | Jones | proto1 | Christie | 50 | 250 |
+-------+---------+----------+---------+-----------+----------+-------+---------+
Thanks for your suggestions!