- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In MySQL, how FIELD() function is different from FIND_IN_SET() function?
As we know, both the functions are used to search a string from the arguments provided in them but there are some significant differences between them as follows −
FIND_IN_SET() − function uses the string list that is itself a string containing the substring separated by commas. Whereas, FIELD() function contains list of different strings among which it will find the index number of the string, if present, which is to be searched.
FIND_IN_SET() − function returns NULL if any of the argument i.e. either search string or string list is NULL. In contrast, FIELD() function do not returns NULL but returns 0 if search string is NULL.
Example
mysql> Select FIND_IN_SET(NULL,'Ram is a good boy') AS Result; +--------+ | Result | +--------+ | NULL | +--------+ 1 row in set (0.00 sec) mysql> SELECT FIND_IN_SET('RAM',NULL)AS RESULT; +--------+ | RESULT | +--------+ | NULL | +--------+ 1 row in set (0.00 sec) mysql> Select FIELD(NULL,'Ram','is','good','boy'); +-------------------------------------+ | FIELD(NULL,'Ram','is','good','boy') | +-------------------------------------+ | 0 | +-------------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- What is the use of FIND_IN_SET () function in MySQL?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- When MySQL FIND_IN_SET() function returns NULL as output?
- What is MySQL HEX() function and how it is different from CONV() function?\n
- MySQL field() function?
- In MySQL, how CEILING() and FLOOR() functions are different from ROUND() function?
- How can MySQL FIND_IN_SET() function be used to get the particular record(s) from the table as a result set?
- How MySQL LOCATE() function is different from its synonym functions i.e. POSITION() and INSTR() functions?
- How to return table from MySQL function?
- What MySQL returns if the search string, provided in FIELD() function, is NULL?
- Which function is a synonym of MySQL LENGTH() function?
- How EXPORT_SET() function works in MySQL?
- Using Aggregate function to fetch values from different tables in SAP
- What is MySQL ELT() function?
- What is MySQL MAKE_SET() function?

Advertisements