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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -