About Clik  | abdi_issa@hotmail.com
Search
Home Somali Internet Software Downloads Education Books Join
HTML JavaScript VBScript SQL PL/SQL ASP Java C++
&nsbp; Click here to buy & sell on eBay!  Accept credit cards Now!
SQL Basics
Introduction
Create Tables
Data Types
Delete/Modify Tables
Adding new rows
Create Sequences
Retreive Data [Query]
Sub Queries
Single-Row Functions
Group Functions
Formating Data
Joining Multiple Tables
Creating View
 

Sub Queries

Sub queries is select statement that appears as part of another SQL statement.  Sub query is used when comparing data from different tables is parenthesized whiting the where clause.
SELECT first_name, last_name
FROM employees
WHERE department_id = (SELECT department_id
                                        FROM department
                                        WHERE section_id = 1112);
The above sample lists first name and last name of all the employees from section 1112.  You can tell that the section ID is not in the employee table department ID is, and section ID is in the department table.
SELECT first_name, last_name
FROM employee
WHERE employee_id = (SELECT employee_id
                                        FROM managers);
This sub query lists employees whom exist both in the employees and managers tables

Retrieve Data (Quiry) Single-Row Functions