Difference between IN and FIND_IN_SET

Posted by Madhan ayyasamy on Mad Han RoR Tips See other posts from Mad Han RoR Tips or by Madhan ayyasamy
Published on 2010-12-02T01:58:00.000-08:00 Indexed on 2010/12/06 16:59 UTC
Read the original article Hit count: 313

Filed under:
Hi Friends,

You may be confused with IN() and FIND_IN_SET() MYSQL functions. There are specific case/situation for both functions where to use which Mysql function. Look at below explanation about IN() and FIND_IN_SET()

IN() : This function is used when you have a list of possible values and a single value in your database.

Example: WHERE memberid IN (1,2,3)

FIND_IN_SET() : This function is used where you have comma separated list of values stored in database and want to see if a certain value exists in that comma seperated list.

Example: WHERE FIND_IN_SET( ‘table column name like id’, 'dynamic idlist' )

© Mad Han RoR Tips or respective owner

Related posts about mysql