Difference between IN and FIND_IN_SET in MySQL

Published On: 14 August 2018.By .
  • General
  • Product & platform Engineering

Most of people thinks IN() and FIND_IN_SET() MySQL functions are identical and do the same job.

But they not. You may be confused with them or don’t know when to use IN() or FIND_IN_SET().There are specific situation for both MySQL functions.

To understand it better assume a table user


userid name age fav_color
1 Hitesh Shrimali 29 Green, Blue
2 Jeetendra Sharma  31 Blue, Pink
3 Ram Singh 29 Red, Blue
  • IN() mysql Function

This function is used when we want to compare field (which contain single value) with list of values in database.

Result – query will return 2 rows with userid 1 and 2.

  • FIND_IN_SET() mysql function

This function is used when any field holds comma separated values in it and we want to compare it with single value.

Result – query will return 1 row with userid 1.

I hope these will clear your confusion and help you to decide when to use one of them.

Related content

Got an Idea?

Let’s create a better tomorrow together