If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help matching best match (using REGEXP)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-24-10, 14:49
mc_line mc_line is offline
Registered User
 
Join Date: Nov 2010
Posts: 1
Help matching best match (using REGEXP)

Hi

I have a table full of regexes (like the one bellow)

part_match
^FF2
^FF2-0F4J
^FF2|FGD[12|21]FSFF

I need a query to retrieve the part_match of the BEST match for 'FF2-0F4J-YJKNC'

I tried going 'FF2-0F4J-YJKNC' regexp match_match ORDER BY length( part_match ) DESC and grab the first row returned, but will not work because this will return row 3 first but the best match is row

Does any one know how to solve this problem by only using a MYSQL query?

Note
Obviously this is an example, the actual table is huge and I need something works for any input


Thank you !!

Last edited by mc_line; 11-24-10 at 14:53.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On