- 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
How MySQL evaluates if we use EXISTS operator with the subquery that returns NULL?
If a subquery, used with EXIST operator, returns NULL, the expression EXIST NULL returns TRUE and MySQL returns the result based on an outer query. It can be understood with the help of simple example using the following data from table ‘Customers’ −
mysql> Select * from Customers; +-------------+----------+ | Customer_Id | Name | +-------------+----------+ | 1 | Rahul | | 2 | Yashpal | | 3 | Gaurav | | 4 | Virender | +-------------+----------+ 4 rows in set (0.00 sec)
The MySQL query below is having the subquery with EXIST operator that returns NULL. In this case, the expression EXIST NULL returns TRUE hence the result set is based upon the outer query.
mysql> SELECT Name from Customers Where EXISTS(Select NULL); +----------+ | Name | +----------+ | Rahul | | Yashpal | | Gaurav | | Virender | +----------+ 4 rows in set (0.00 sec)
- Related Articles
- How MySQL evaluates if we use EXISTS operator with a subquery that returns no rows?
- How MySQL SUM() function evaluates if it is used with SELECT statement that returns no matching rows?
- How can we use a MySQL subquery with INSERT statement?
- How can we use a MySQL subquery with FROM clause?
- What MySQL returns when we use DISTINCT clause with the column having multiple NULL values?
- What MySQL returns if we use UNIX_TIMESTAMP() function with no argument?
- How MySQL SUM() function evaluates if the column having NULL values too?
- MySQL query that returns a specific string if column is null?
- How MySQL evaluates if we export the data to CSV file from a table which contains a NULL value(s)?
- How can we filter data with the help of MySQL subquery?
- How can we create a MySQL view with a subquery?
- What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?
- What MySQL returns if the argument of QUOTE() function is NULL?
- Why we cannot use comparison operator(=) for getting the rows with NULL from a table?
- How MySQL evaluates if I will use an expression within SUM() function?

Advertisements