mysql - SQL - Query to find if a string contains part of the value in Column -


i trying write query find if string contains part of value in column (not confuse query find if column contains part of string). example have column in table values abc,xyz. if give search string abcdefg want row abc displayed. if search string xyzdsds row value xyz should displayed

the answer "use like".

see documentation: https://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html

you can where 'string' concat(column , '%')

thus query becomes:

select * t1 'abcdefg' concat(column1,'%'); 

if need match anywhere in string:

select * t1 'abcdefg' concat('%',column1,'%'); 

here can see working in fiddle: http://sqlfiddle.com/#!9/d1596/4


Comments

Popular posts from this blog

python - Overwriting the save method of a Django model -

java - how to browse all messages from 2 different MQQueue in the same function? -

How to run C# code using mono without Xamarin in Android? -