MySQL Substring Index Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adnankatmer
    New Member
    • May 2010
    • 1

    MySQL Substring Index Problem

    Hello,

    As much as I understand, MySql does not support indexes on substring selects. I have need a query like:

    Code:
    					SELECT 
    						DISTINCT C.CODE, 
    						C.NAME
    					FROM 
    						mtt_table1 A,
    						mtt_table2 B,
    						mtt_table3 C,
    						mtt_table4 D
    					WHERE 1
    						AND (C.NAME LIKE '%abc%' OR C.KEYWORDS LIKE '%abc%')
    						AND ( SUBSTRING(B.GTIP,1,4) = A.GTIP or SUBSTRING(B.GTIP,1,6) = A.GTIP OR SUBSTRING(B.GTIP,1,8) = A.GTIP )
    						AND C.CODE = B.CODE
    						AND D.GTIP = A.GTIP
    How can I do it with indeses. I have billons of rows in the tables.

    Thanks
    Adnan
Working...