rendered paste bodySELECT
o.*,
date_format(o.d_date,'%d.%m.%Y') as fmt_date,
p.d_name as d_person,
concat(if (mk.d_make is not null,mk.d_make,if(p_make.d_value='muu',p_make_other.d_value,'')),' ',if (md.d_model is not null,md.d_model,if(p_model.d_value='muu',p_model_other.d_value,''))) as d_vehicle
FROM
bkm_offer o
LEFT JOIN bkm_person p ON o.person_id=p.person_id
LEFT JOIN bkm_offer_properties p_make ON p_make.offer_id=o.offer_id and p_make.d_property='make'
LEFT JOIN bkm_make mk ON p_make.d_value=mk.make_id
LEFT JOIN bkm_offer_properties p_make_other ON p_make.offer_id=o.offer_id and p_make.d_property='make_other'
LEFT JOIN bkm_offer_properties p_model ON p_model.offer_id=o.offer_id and p_model.d_property='model'
LEFT JOIN bkm_model md ON p_model.d_value=md.model_id
LEFT JOIN bkm_offer_properties p_model_other ON p_model.offer_id=o.offer_id and p_model.d_property='model_other'
WHERE
o.d_type=1
ORDER BY
o.offer_id desc
LIMIT 100
+----+-------------+---------------+--------+---------------+---------+---------+-------------------------+--------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------------+--------+---------------+---------+---------+-------------------------+--------+----------------------------------------------+
| 1 | SIMPLE | o | ALL | NULL | NULL | NULL | NULL | 616 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | p | eq_ref | PRIMARY | PRIMARY | 4 | bkmnew.o.person_id | 1 | |
| 1 | SIMPLE | p_make | eq_ref | PRIMARY | PRIMARY | 769 | bkmnew.o.offer_id,const | 1 | |
| 1 | SIMPLE | mk | eq_ref | PRIMARY | PRIMARY | 4 | bkmnew.p_make.d_value | 1 | |
| 1 | SIMPLE | p_make_other | ALL | NULL | NULL | NULL | NULL | 104707 | |
| 1 | SIMPLE | p_model | eq_ref | PRIMARY | PRIMARY | 769 | bkmnew.o.offer_id,const | 1 | |
| 1 | SIMPLE | md | eq_ref | PRIMARY | PRIMARY | 4 | bkmnew.p_model.d_value | 1 | |
| 1 | SIMPLE | p_model_other | ALL | NULL | NULL | NULL | NULL | 104707 | |
+----+-------------+---------------+--------+---------------+---------+---------+-------------------------+--------+----------------------------------------------+
8 rows in set (0.00 sec)