SELECT
*
FROM
pages
INNER JOIN cms_collection ON cms_collection.collection_id LIKE
(
CONCAT('%', pages.page_id, '/heading%') OR
CONCAT('%', pages.page_id, '/content%')
)
WHERE
site_id = 51
LIMIT 10
The stacked CONCATs are causing the query to be super slow, is there anyway to optimize this? And actually it seems like this statement isn't working as expected.. I want to do a LIKE based on if the collection_id is '%pages.page_id/heading%' OR '%pages.page_id/content%'.
This statement works fine if just the first CONCAT exists.