0
SELECT * FROM TABLE_NAME WHERE 'string' in ('string1','string2','string3')

Its not given correct result find_in_set only given a exact result. If any way to get correct result without using find_in_set

Nic3500
  • 8,144
  • 10
  • 29
  • 40
  • 2
    Possible duplicate of [FIND\_IN\_SET() vs IN()](https://stackoverflow.com/questions/4155873/find-in-set-vs-in) – raina77ow Aug 28 '18 at 10:01

1 Answers1

0

SELECT * FROM TABLE_NAME WHERE 'string' in ('string1','string2','string3');

In the above query, string is supposed to be a field (column) so, if you were to have this query work, it would be without single quotes ', like this:

SELECT * FROM TABLE_NAME WHERE string IN ('string1','string2','string3');

This will return all rows where the field string is exactly string1 or string2 or string3.


Now, if you want to query the field string for values like "string", not exactly matching, then you use the LIKE operator:

SELECT * FROM TABLE_NAME WHERE string LIKE '%string%';

In the above query, all 3 records containing string1, string2 and string3 will be returned.

AmmoPT
  • 958
  • 1
  • 9
  • 16
  • In my case i can't use '%like%' because my strings are like ('a','aa','aaa'). So if i put like "%aa%" it returns aa,aaa – Aro Infantraj Aug 29 '18 at 04:36
  • @AroInfantraj https://stackoverflow.com/questions/656951/search-for-whole-word-match-in-mysql – AmmoPT Aug 29 '18 at 14:47