Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone tell me how to use exists in SQL?

1 Answer

0 votes
by (119k points)
edited by

EXISTS operator is used to checking whether the records exist in the subquery and returns true if exists.

Here is the syntax to use EXISTS operator in SQL:

SELECT column_list
FROM Table_Name
WHERE EXISTS
(SELECT Column_Name FROM Table_Name  WHERE condition(s));

Here is the statement to find the names of customers who placed a minimum of one order (using EXISTS operator) :

SELECT Customer_Name

FROM Customers

WHERE EXISTS (SELECT *

                                FROM Orders

                                WHERE Customers.customer_id = Orders.customer_id)

You can check out this SQL tutorial to learn using EXIST operators with examples.

Related questions

0 votes
1 answer
asked May 4, 2020 in SQL by Sudhir_1997 (55.6k points)
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
3 answers
asked Jul 4, 2019 in SQL by Tech4ever (20.3k points)

Browse Categories

...