In MySQL database I have table item with some columns describing items, and another table itemExtendedFields. The second one has columns: id, itemId, name, value. In the itemExtendedFields additional information about items are stored.
Some items have expiry date that can be constructed from two values kept in two rows of itemExtendedFields table.
For example for an item with itemId = 34 i have following two rows in itemExtendedFields:
id | itemId | name | value
--------------------------
87 | 34 | ExpiryYear | 2014
88 | 34 | ExpiryMonth | 2
I need to write query that selects all items from items along with expiryYear and ExpiryMonth values from itemExtendedFields table in separate columns. Moreover i need to select items that will expire on given date (for example February 2014). I have no idea how to construct proper query. I cannot change the construction of the tables.
this will list all columns from
itemstable along with theExpiryYearandExpiryMonthfrom theitemExtendedFieldstable.