As we all know, both functions are used to search strings based on the arguments they provide, but there are some significant differences between them as shown below
mysql> Select IF(INSTR('10,11,12,13',2) > 0,1,0) As Result; +--------+ | Result | +--------+ | 1 | +--------+ 1 row in set (0.05 sec) mysql> Select IF(FIND_IN_SET(2,'10,11,12,13') > 0,1,0)As Result; +--------+ | Result | +--------+ | 0 | +--------+ 1 row in set (0.00 sec)
From the result set of the above example, we can see that the INSTR() function returns 1 or even 2 because the character does not exist in the parameter string. But the FIND_IN_SET() function returns 0, which is the correct answer.
The above is the detailed content of What is the difference between the MySQL INSTR() and FIND_IN_SET() functions?. For more information, please follow other related articles on the PHP Chinese website!