Nested queries, Database Management System

Nested Queries

Let us see some more complex queries in this section.

Sub-queries:

Some of the basic concerns of sub-queries are:

  • A sub-query is a SELECT statement that is fixed in a clause of another SELECT statement. They are often referred to as a SUB SELECT or NESTED SELECT or INNER SELECT.
  • The sub-query (inner query) implements first before the main query. The product of the sub-query is used by the outer query (main query).
  • Sub-query can be placed in HAVING or WHERE or FROM clauses.
  • Format of using sub-queries:

                 SELECT

                 FROM

                 WHERE expr OPERATOR

                                                          (SELECT FROM

WHERE);

                Operator has a comparison operator (one or multiple row operators)

Single row operator:   >, =, >=, <, <=, <>

                         Multiple row operators: IN, ALL, ANY,

  • Order by clause can't be used in sub-query, if specified it must be the end clause in the main select statement.
  • Parts of sub-queries:

         ‰  Single row sub-query: It gives only single row from the inner select statement.

        ‰   Multiple row sub-queries: It gives more than single row from the inner select statement

        ‰  Multiple column sub-queries: It gives more than single column from the inner select statement.

Single row operators are used with one row sub queries and multiple row operators are used with numerous row sub queries.

  • The Inner and Outer queries can get data from different tables.
  • Group Functions are used in sub queries.
Posted Date: 3/11/2013 3:36:58 AM | Location : United States







Related Discussions:- Nested queries, Assignment Help, Ask Question on Nested queries, Get Answer, Expert's Help, Nested queries Discussions

Write discussion on Nested queries
Your posts are moderated
Related Questions
What is relational model feature? A relational model feature is much more data independence than some other database models.

Natural Join : It is the similar like Equi join except one of the duplicate columns is removed in the result table. The natural join is the most usually used form of join operation

What is a Data Flow Diagram?  Data Flow Diagram: A data flow diagram is the graph that shows flow of data values from their sources in objects in the course of processes whic

Example RELATION SCHEMA for STUDENT: STUDENT (Roll No: string, name: string, login: string, age: integer) RELATION INSTANCE

What is the function of SQL Server Agent Windows service? - It's a Windows service that handles tasks scheduled within SQL Server environment. These tasks are also known as job

You want to implement following relationships when designing tables. How would you do it? a.) One-to-one b.) One-to-many c.) Many-to-many a.) One-to-One relationship -


What are the disadvantages of relational approach? Disadvantages of relational approach: • Substantial hardware and system software overhead • May not fit all business models •

What is RDBMS terminology for a row? A tuple is a RDBMS terminology for a row