What is subquery?

Total Post:55

Points:275

 153  View(s)
Ratings:
Rate this:
  1. What is subquery?

    The subquery is a query within another query. The outer query is called as the main query, and the inner query is called subquery. The SubQuery is always executed first, and the result of the subquery is passed on to the main query.

    • The subquery is a SQL query within a query.
    • The subqueries are nested queries that provide data to the enclosing query.
    • The subqueries can return individual values or a list of records
    • The subqueries must be enclosed with parenthesis
    Example:-
    
    SELECT column_name
    FROM table_name
    WHERE column_name expression operator
        ( SELECT COLUMN_NAME from TABLE_NAME WHERE ... );
    Select NAME, LOCATION, PHONE_NUMBER from DATABASE 
    
    WHERE ROLL_NO IN
    (SELECT ROLL_NO from STUDENT where SECTION=’A’); 

      Modified On Jul-04-2019 11:11:59 PM

Answer