Difference Between WHERE FIND_IN_SET(…)>0 and WHERE FIND_IN_SET(…) in SQL
Last Updated :
30 Nov, 2021
FIND_IN_SET(...): This function returns the index(starting from 1) of the required string in a given list of strings if it is present in the list. If the required string is absent in the given list of strings, then 0 is returned.
Syntax:
SELECT FIND_IN_SET(REQUIRED_STRING,
LIST_OF_STRINGS);
FIND_IN_SET(...)>0: This function returns only 2 values i.e. either 1 or 0. 1 is returned if the required string is present in the given list of strings and 0 is returned if the required string is absent in the given list of strings.
Syntax:
SELECT FIND_IN_SET(REQUIRED_STRING,
LIST_OF_STRINGS)>0;
The following cases arise:
- When the REQUIRED_STRING is present in the given LIST_OF_STRINGS.
Query:
SELECT FIND_IN_SET("STUDENT",
"PARENT,STUDENT,TEACHER");
Output:

Query:
SELECT FIND_IN_SET("STUDENT",
"PARENT,STUDENT,TEACHER")>0;
Output:

- When the REQUIRED_STRING is absent in the given LIST_OF_STRINGS.
Query:
SELECT FIND_IN_SET("PEON",
"PARENT,STUDENT,TEACHER");
Output:

Query:
SELECT FIND_IN_SET("PEON",
"PARENT,STUDENT,TEACHER")>0;
Output:

When either the required string or the given list of strings is empty i.e. equal to "", then 0 is returned by both the functions. Similarly, when either the required string or the given list of strings is NULL, then NULL is returned by both the functions
Thus, we can observe that the main difference between FIND_IN_SET(...) and FIND_IN_SET(...)>0 arises when the required string is present in the given list of strings. In this case, the FIND_IN_SET(...) function returns the index(starting from 1) of the required string whereas the FIND_IN_SET(...)>0 function returns 1 irrespective of the position of the required string.
Similar Reads
What is the Difference Between NOT EXISTS and NOT IN SQL Server? When applying filters on a result set that is stored in SQL Server, there are occasions where one wants to apply conditions where specific records exist or do not exist. Not exists and not in are two of the most basic, but deciding when to use them can be a real challenge. In this article, we will l
7 min read
Difference between Inner Join and Outer Join in SQL JOINS in SQL are fundamental operations used to combine data from multiple tables based on related columns. They are essential for querying data that is distributed across different tables, allowing you to retrieve and present it as a single or similar result set.In this article, We will learn about
5 min read
Difference Between EXISTS and IN in SQL Server? The SQL Server database developer is quite familiar with the filtering and retrieving operators which enable the developer to execute the query rapidly. When it comes to these operators namely IN and EXISTS, they share almost similar purposes but work differently at the same level. Understanding the
4 min read
Difference Between EXISTS and IN in PostgreSQL PostgreSQL is one of the most advanced general-purpose object-relational database management systems and is open-source. Being an open-source software, its source code is available under the PostgreSQL license, a liberal open-source license. In this article, we will learn about the EXISTS and IN Con
6 min read
Difference between Where and Having Clause in SQL In SQL, the WHERE and HAVING clauses are essential for filtering data and refining query results. While both serve the purpose of applying conditions, they are used at different stages of query execution and for distinct purposes. Understanding the differences between the WHERE and HAVING clauses is
3 min read