I have a table with the structure in the image. A post is conformed by all the rows with the same lead_id (17 fields in total). That said, how can I filter posts by a field_value? For instance query all the posts that has the field_value "ibague". Doing that with that table structure seems to be tricky. I was thinking of creating another table with primary key lead_id and create a column for every one of the 17 fields, and exporting the data with some horrible cursor in mysql, or some loop in php, and then make the query in a table easier to query. But with that approach I would have to create manually another column if a new field is added, and export the new data every time someone access to the report module. Any ideas my fellow programmers?
Thanks a lot.