php - Text searching to compare against Mysql database tables -


let's have string containing words. of these words may compound words.

i have mysql database contains table contains column called words. column may contain words appear in string, including compound words.

i able find out rows retrieve database, when have string. splitting on space characters not option, because make impossible detect if compound words database appear in string.

any suggestions how solve issue?

you can following approach. let's assume string has space separator , never contains comma.

select * words w find_in_set(w.word, replace(<your string>, ' ', ',')) > 0; 

if delimiters in string bit more complicated -- have punctation, might better off regexp rather find_in_set:

select * words w concat(',', <your string>, ',') regexp concat('[ ,.!?]', w.word, '[ ,.!?]') 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -