Data 360 SQL and Tableau Hyper API
Type Conversions
ALL
ANY and SOME
EXISTS
IN
NOT IN
Logical Operators
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
EXISTSApplies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Tests whether a subquery returns any rows. Returns a boolean result.
1EXISTS ( <subquery> )<subquery>: An arbitrary SELECT statement. The subquery is evaluated to determine whether it returns any rows. It can refer to variables from the surrounding query, which act as constants during any one evaluation of the subquery.Returns true if the subquery returns at least one row, and false if the subquery returns no rows.
EXISTS expressions in the form EXISTS (SELECT 1 WHERE ...). Exceptions to this convention include subqueries that use INTERSECT or EXCEPT.Find rows in one table that have a matching row in another. This example is similar to an inner join on col2, but it produces at most one output row for each tab1 row, even if there are several matching tab2 rows.
1SELECT col1
2FROM tab1
3WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2);