exists subqueries

SELECT * FROM USER u WHERE 
EXISTS (SELECT 1 FROM USER s WHERE u.t_id=s.t_id AND s.t_username='小明')

 

Description: Performs principle,

Process Exists Exists outer query execution is executed first, and then execute the query memory, and IN the opposite. To first remove the outer flow

The first layer is a tuple, then execute the inner query, the outer table of the first element group is substituted, if the inner query is true, that is the result

Time. Returns the outer first tuple in the table, and then remove the second tuple, performs the same algorithm. Until the entire table has been scanned layer 

Guess you like

Origin www.cnblogs.com/fangyan1994/p/11247400.html