I currently have the following EAV table:
id
field_name
field_value
And a standard table:
id
first_name
last_name
I am joining the standard table onto the EAV table for each value that matches the ID, so my query looks something like this:
SELECT id, first_name, last_name, fieldname1, fieldname2
FROM standard_table
LEFT JOIN EAV AS fieldname1 ON
(fieldname1.id = standard_table.id AND fieldname1.field_name = 'fieldname1')
LEFT JOIN EAV AS fieldname2 ON
(fieldname2.id = standard_table.id AND fieldname2.field_name = 'fieldname2');
This has been working fine, up until today where I now have 62 custom fields in my EAV table, this means that my query is joining onto 62 tables and so hitting the MySQL table join limit and failing.
The whole query seems like a bad way of doing it, how can I rewrite this so it is quicker and doesn't require 62 table joins.