SQL Sub-queries
- A sub-query is a SQL query within a query.
- Sub-queries are nested queries that provide data to the enclosing query.
- Sub-queries can return individual values or a list of records
- Sub-queries m
The SQL sub-query syntax
There is no general syntax; sub-queries are regular queries placed inside parenthesis.Sub-queries can be used in different ways and at different locations inside a query:
Here is an sub-query with the IN operator
- SELECT column-names FROM table-name1 WHERE value IN (SELECT column-name FROM table-name2 WHERE condition)
Sub-queries can also assign column values for each record:
- SELECT column1 = (SELECT column-name FROM table-name WHERE condition),column-names FROM table-name WHERE condition
Comments
Post a Comment