- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
What would be the effect on MySQL output if we have the combination of NULL and other values in the list of strings, provided as arguments in FIELD() function?
There will be a significant change in the output if we have the combination of NULL and other values in the list of strings, provided as arguments in FIELD() function. Following example will demonstrate it
Example
mysql> Select FIELD('good','Ram','is','good','boy'); +---------------------------------------+ | FIELD('good','Ram','is','good','boy') | +---------------------------------------+ | 3 | +---------------------------------------+ 1 row in set (0.00 sec)
As we can observe from the above output the index number of search string ‘good’ is 3. Now, if we will add NULL in the list of string then there will be a significant change in the output as follows −
mysql> Select FIELD('good','Ram','is',NULL,'good','boy'); +---------------------------------------------+ | FIELD('good','Ram','is',NULL,'good','boy') | +---------------------------------------------+ | 4 | +---------------------------------------------+ 1 row in set (0.00 sec)
It means that MySQL will compare the search string with NULL also.
Advertisements