SELECT cm.id, cm.hash, cm.user_id, cm.message, cm.status, cm.created, user.firstname AS user_firstname, user.lastname AS user_lastname, user.email AS user_email, mute.status AS user_mute_status, mute.set AS user_mute_set, mute.seconds AS user_mute_seconds, profi_i.image_path AS avatar_image_image_path, profi_i.image_x AS avatar_image_image_x, profi_i.image_y AS avatar_image_image_y, profi_i.is_high_res AS avatar_image_is_high_res, profi_d.image_path AS avatar_detailed_image_path, profi_d.image_x AS avatar_detailed_image_x, profi_d.image_y AS avatar_detailed_image_y, profi_d.is_high_res AS avatar_detailed_is_high_res, profil.pair_id AS avatar_pair_id, profil.image_id AS avatar_image_id, profil.detailed_id AS avatar_detailed_id FROM cscart_chat_messages AS cm  LEFT JOIN cscart_users as user ON user.user_id = cm.user_id LEFT JOIN cscart_chat_mutes as mute ON user.user_id = mute.user_id  LEFT JOIN cscart_profile_images_links as profil  ON user.user_id = profil.profile_id AND field_name = "avatar"  LEFT JOIN cscart_profile_images as profi_i  ON profi_i.image_id = profil.image_id  LEFT JOIN cscart_profile_images as profi_d  ON profi_d.image_id = profil.detailed_id WHERE 1   ORDER BY cm.id DESC   LIMIT 0, 25

Query is invalid

JSON explain

{
  "query_block": {
    "select_id": 1,
    "const_condition": "1",
    "table": {
      "table_name": "cm",
      "access_type": "index",
      "key": "PRIMARY",
      "key_length": "4",
      "used_key_parts": ["id"],
      "rows": 12,
      "filtered": 100
    },
    "table": {
      "table_name": "user",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["user_id"],
      "ref": ["dev.cm.user_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "trigcond(`user`.user_id = cm.user_id)"
    },
    "table": {
      "table_name": "mute",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY"],
      "key": "PRIMARY",
      "key_length": "4",
      "used_key_parts": ["user_id"],
      "ref": ["dev.user.user_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "trigcond(`user`.user_id = mute.user_id and trigcond(`user`.user_id is not null))"
    },
    "table": {
      "table_name": "profil",
      "access_type": "ref",
      "possible_keys": ["profile_id"],
      "key": "profile_id",
      "key_length": "102",
      "used_key_parts": ["profile_id", "field_name"],
      "ref": ["dev.user.user_id", "const"],
      "rows": 2,
      "filtered": 100,
      "attached_condition": "trigcond(`user`.user_id = profil.profile_id and profil.field_name = 'avatar' and trigcond(`user`.user_id is not null))"
    },
    "table": {
      "table_name": "profi_i",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY"],
      "key": "PRIMARY",
      "key_length": "4",
      "used_key_parts": ["image_id"],
      "ref": ["dev.profil.image_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "trigcond(trigcond(profil.image_id is not null))"
    },
    "table": {
      "table_name": "profi_d",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY"],
      "key": "PRIMARY",
      "key_length": "4",
      "used_key_parts": ["image_id"],
      "ref": ["dev.profil.detailed_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "trigcond(trigcond(profil.detailed_id is not null))"
    }
  }
}