What Is a Subquery in a SELECT Query Statement in SQL Server

Q

What Is a Subquery in a SELECT Query Statement in SQL Server?

✍: FYIcenter.com

A

A subquery is a SELECT statement used as part of the selection criteria of the main SELECT statement. The subquery specified in the WHERE clause will be evaluated repeated on each row of the selection base table. The output of the subquery will be used in the final evaluation of the criteria. Usually, subqueries are used in the following Boolean operations:

  • "expression IN (subquery)" - True if the expression matches one of the returned values from the subquery.
  • "expression NOT IN (subquery)" - True if the expression does not match any of the returned values from the subquery.
  • "EXISTS (subquery)" - True if the subquery returns one or more rows.
  • "NOT EXISTS (subquery)" - True if the subquery returns no rows.

 

Using Subqueries with the IN Operators in SQL Server

"AS" - Naming Query Output Columns in SQL Server

Using SELECT Statements with Joins and Subqueries in SQL Server

⇑⇑ SQL Server Database Tutorials

2016-10-29, 1288🔥, 0💬