Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » SQL Anywhere Server - SQL Usage » Query and modify data

 

Use of subqueries

With a relational database, you can store related data in more than one table. In addition to being able to extract data from related tables using a join, you can also extract it using a subquery. A subquery is a SELECT statement nested within the SELECT, WHERE, or HAVING clause of a parent SQL statement.

Subqueries make some queries easier to write than joins, and there are queries that cannot be written without using subqueries.

Subqueries can be categorized in different ways:

  • whether they can return one or more rows (single-row vs. multiple-row subqueries)

  • whether they are correlated or uncorrelated

  • whether they are nested within another subquery


Single-row and multiple-row subqueries
Correlated and uncorrelated subqueries
Nested subqueries
Use of subqueries instead of joins
Subqueries in the WHERE clause
Subqueries in the HAVING clause
Subquery testing
Optimizer automatic conversion of subqueries to joins