I have a PK of
(id1, id2, col4, col5)
This query successfully uses my index except for the last LIKE (which is very usable):
SELECT *
FROM table1
WHERE id1 = 2 AND id2 = 1 AND col4 LIKE 'min%' AND col4 LIKE '%hou%'
I'm wondering how to rewrite this query (or if it's possible) so it too uses the index at least for part of the query. I've unsuccessfully tried several ways using UNION, but here's what I started with:
SELECT *
FROM table1
WHERE id1 = 2 AND id2 = 1 AND col4 LIKE 'min%'
OR col5 LIKE 'min%' AND (col4 LIKE '%hou%' OR col5 LIKE '%hou%')
Thanks for taking a look.