mysql - How to SELECT with all index of SUBSTRING_INDEX -


i have table this

table foo1

+----+------------------------------+ | id | content                      | +----+------------------------------+ | 1  | hello world                  | +----+------------------------------+ | 2  | hello users                  | +----+------------------------------+ | 3  | post submitted users | +----+------------------------------+ | 4  | c# programming               | +----+------------------------------+ 

i send parameter stored procedure 'hello,users,post'. want split parameter comma(,) , rows contains indexes (hello or users or post). if send 'hello,users' return table should (contains hello or users)

+----+------------------------------+ | 1  | hello world                  | +----+------------------------------+ | 2  | hello users                  | +----+------------------------------+ | 3  | post submitted users | +----+------------------------------+ 

i have tried query

select     * foo1 foo1.content  concat('%',substring_index('hello, users, post', ',', 1),'%'); 

but returns rows contain 'hello'. parameter's word flexible. can contains countless word. can 'hello, post, users' or 'hello' or 'hello,post'. how can solve this?

thanks.

use regexp function.

select *  foo1  foo1.content regexp 'hello|users|post';  

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -