\begin{frame} \frametitle{Not Exists} \begin{alertblock}{} The subquery may use tuple variables from outer query.\\ The \emph{converse is illegal}! \end{alertblock} \bigskip \begin{code}{\textwidth}{Wrong!} \small $ \begin{array}{ll} \sql{select} & \sql{first, last, {\setlength{\fboxsep}{2pt}\fbox{R.number}}} \\ \sql{from} & \sql{Students S} \\ \sql{where} & \sql{not exists (} \begin{array}[t]{@{\,}ll} \sql{select} & \sql{*} \\ \sql{from} & \sql{Results R} \\ \sql{where} & \sql{R.category = \textquotesingle{}homework\textquotesingle{}} \\ \sql{and} & \sql{R.sid = S.sid)} \end{array} \end{array} $ \end{code} \vspace{-1ex} Compare this to \emph{variable scoping} (global/local variables) in block-structured programming languages (Java, C). \medskip Subquery tuple variables declarations are ``local.'' \end{frame}