regex - How to use REGEXP in mysql for matching words from a text -


i have mysql query :

select name table_name name '%custom%' limit 10 

it retruns me 2 rows custom table.

i want records contains either of word text c cu cus cust usto stom tom om m also.

i tried below query :

select name table_name name '%custom%' or name regexp 'c|cu|cus|cust|usto|stom|tom|om|m' limit 10 

above query returning me 7 records these 7 records not have such 2 records 1st query result have.

how that? or other way these result in mysql?

edit : here want order maximum substrings matches in second query.

try this:

select name table_name name regexp 'custom' limit 10; 

there no need of like regexp, regexp slower like. if table have many records regexp quesries slower.


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -