Zend certified PHP/Magento developer

Magento 2: How can I fix this Category Products index MySQL Error?

I have migrated M1 simple products into my M2 database and as a result have had to remove/edit some incorrect eav_attribute table entities. When I reindex Catalog Products I now get this error which seems ambiguous to me. Can someone tell me how to fix this?

NOTE: my store id is 1 and not 0 as the query says

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'JOIN `catalog_category_entity_int` AS `ccacs` ON ccacs.entity_id = c.entity_i...' at line 3, query was: SELECT MAX(entity_id) as max, COUNT(*) as cnt FROM (SELECT `c`.`entity_id`, `c`.`path` FROM `catalog_category_entity` AS `c`

INNER JOIN catalog_category_entity_int AS ccacd ON ccacd.entity_id = c.entity_id AND ccacd.store_id = 0 AND ccacd.attribute_id =
LEFT JOIN catalog_category_entity_int AS ccacs ON ccacs.entity_id = c.entity_id AND ccacs.attribute_id = ccacd.attribute_id AND ccacs.store_id = 0 WHERE (IFNULL(ccacs.value, ccacd.value) = 1) AND (c.entity_id > 0) ORDER BY c.entity_id ASC
LIMIT 500) AS t