SQL Nested Queries
Tweet |
A SQL nested query is a SELECT query that is nested inside a SELECT, UPDATE, INSERT, or DELETE SQL query. Here is a simple example of SQL nested query:
SELECT Model FROM Product
WHERE ManufacturerID IN (SELECT ManufacturerID FROM Manufacturer
WHERE Manufacturer = 'Dell')
The nested query above will select all models from the Product table manufactured by Dell:
Model |
Inspiron B120 |
Inspiron B130 |
Inspiron E1705 |
You can have more than one level of nesting in one single query.