Right now, I'm developing an application that has dynamic fields. In my table structure:
id|fieldname|fieldvalue
When this begins to populate, searching for data becomes difficult.
IE:
id|fieldname|fieldvalue
1|first_name|John
2|last_name|Doe
3|first_name|Jack
4|last_name|Moe
Now, I want to run a query to find out if there is a match where (first_name = john and last_name = doe) or (first_name=jack and last_name=moe).
Hopefully you can see the problem. Ppl have suggested naming the tables with the fieldnames instead, but this is dynamic fieldnames. The end user could be entering in 50 fieldnames and be removing them on the fly.
MySQL 4.0 has the function called UNION which would be perfect for me, however, we don't want to upgrade from 3.23.41 yet.
So my question is whether there is a better database structure for this type of querying or a work around to simulate UNION queries using PHP.