\begin{frame} \frametitle{Specifying the Join Predicate} \begin{goal}{} The \emph{join predicate} may be specified as follows: \begin{itemize} \smallskip \item \emph{\sql{natural}} prepended to join operator name.\\ \begin{code}{0.8\textwidth}{} \sql{Results natural join Exercises} \end{code}\\ Yields comparison of columns with the same name. \smallskip \item \emph{\sql{using (A1, ..., An)}} after the second table.\\ \begin{code}{0.8\textwidth}{} \sql{Results join Exercises using (category,number)} \end{code}\\ The $A_i$ must be columns appearing in both tables. The join predicate then is \sql{R.A1 = S.A1 and} \ldots \sql{and R.An = S.An}. \smallskip \item \emph{\sql{on (condition)}} after the second table.\\ \begin{code}{0.8\textwidth}{} \sql{Students S join Results R on (S.sid = R.sid)} \end{code}\\ The matching condition works similar to the where clause, but is important in combination with left/right joins. \smallskip \end{itemize} The \sql{cross join} operator (next slide) has no join predicate. \end{goal} \end{frame}