MySQL - Getting historical "snapshots" from a history table -


I have a MySQL database, which is wired in many relationship fields (such as order and order_itm), each time an order_itm change The record is also entered in the order_tom_history table with the timestamp in the modified field.

What I need to do is ask the database to get the position of the order on a given date basis. To get the latest version of a particular order_item, I

SELECT * from order_item_history where order_item_id = 4 and modify & lt; ORDER RECOMMENDED DECC Border 1

I did not know how to write a query that would work as above, except that order based on order_id field

I can do this programmatically in PHP by inserting order_item_ids in an array and running a query for every one, but I think it is mysql There is a way to do it.

Any help greatly appreciated.

Try -

  SELECT * to order_item o OOP IID Oh. ITAM_ID OEID OAIDID = 4 Order Oaid DESC serial 1  

Comments