Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource
gallery w3resource

SQL Subquery

Transcript

SQL Subquery

<!doctype html>
<html lang="en">
<head>
<title>SQL Subquery </title>
</head>
<body>
</body>
</html>

What is SQL Sqbquery?

A subquery is a SQL query nested inside a larger query.

Where Subquery Occurs?

A subquery may occur in -

  • A SELECT clause
  • A FROM clause
  • A WHERE clause
  • The subquery can be nested inside a SELECT,INSERT,UPDATE,or DELETE statement or inside another subquery.
  • A subquery is usually added within the WHERE Clause of another SQL SELECT statement.
  • You can use the comparison operators, such as >, <, or =.

Subquery Syntax

  • The subquery (inner query) executes before the main query (outer query).
  • The result of the subquery is used by the main query.

Type of Subqueries

  • Single row subquery : Returns zero or one row.
  • Multiple row subquery : Returns one or more rows.
  • Multiple column subquery : Returns one or more columns.
  • Correlated subqueries : Reference one or more columns in the outer SQL statement.
  • Nested subqueries : Subqueries are placed within another subqueries.