Programming in mysql: Complication on one-to-many query on newest questions tagged mysql – Stack Overflow
Greetings esteemed colleagues. I have to write a reporting query for a kind of versioning system where I need to retrieve date-based reporting variations of the latest version of an item. Simplified table structures are thus:
items_register: ir_id (primary, auto inc), ir_name (varchar)
items: i_id (primary, auto inc), i_register_id (int), i_version_name (varchar), i_datetime (datetime), i_date_expiry (datetime)
Versioning for each item in the register is based upon the i_datetime field, so the highest value is the most recent version.
So say my report user wants to see items where the most recent version is due to expire on a certain date, and say that date is converted to a timestamp called $f_date. The fields I want are items_register.ir_id, items_register.ir_name, items.i_version_name, items.i_datetime.
How do I write this query? TIA.
source: http://stackoverflow.com/questions/10762342/complication-on-one-to-many-query
Programming in mysql: programming-in-mysql
Recent Comments