From the course: Quick Start Guide to SQL

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Uses of subqueries

Uses of subqueries

- [Instructor] Let's learn about subqueries. First of all, what is a subquery? When we write a select statement in a clause of another select statement it is known as a sub query. It is also called inner select or nested select. The inner select statement will be executed first and then its output is taken as input for the outer select and retrieves the data. We'll understand this better when we look at some examples in the next videos These are some of the rules that we need to follow when writing subqueries. Subqueries must be enclosed in parentheses. Subqueries must always come on the right side of the comparison condition. Here when we look at this example, it has been written on the right side of the comparison condition. We cannot give it on this side of the condition and as we see it has been enclosed in parenthesis over here. So these are some simple rules that we need to follow when writing subqueries.

Contents