Jump to content

REGEXP


daled

Recommended Posts

You could use multiple regular expressions and add the matches (0 if no match, 1 if match), and the more that match will be ordered higher.

 

SELECT (col1 RLIKE 'a[bc]') + (col1 RLIKE 'xz[0-9]$') + (col1 RLIKE '^55') AS score
FROM table
WHERE col1 RLIKE 'a[bc]' OR col1 RLIKE 'xz[0-9]$' OR col1 RLIKE '^55'
ORDER BY score DESC, col1

Link to comment
https://forums.phpfreaks.com/topic/60109-regexp/#findComment-299531
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.