In fact, you created the Correlated subquery . The Exists predicate accepts a subquery as input and returns TRUE if the subquery returns any rows and FALSE otherwise.
An external query on table P has no filters, so all rows from this table for which the EXISTS predicate returns TRUE will be considered.
SELECT DISTINCT PNAME
Now the Exists predicate returns TRUE if the current row in table P has related rows in SP Join S ON SP.SNO = S.SNO , where S.STATUS > 25
SELECT * FROM SP Join S ON SP.SNO = S.SNO WHERE SP.PNO = P.PNO
One of the benefits of using the Exists predicate is that it allows you to intuitively formulate English queries as queries. For example, this query can be read in the same way as you would say it in ordinary English: select all unique PNAME from table P , where there is at least one row in which PNO is equal to PNO in table SP and Status in table S > 25 . provided that the table SP and S connected based on SNO .
source share