0% found this document useful (0 votes)
13 views4 pages

DBMS Experiment No 8

The document outlines an experiment focused on implementing subqueries in SQL, which are nested queries used within other SQL statements. It explains the usage of subqueries for various commands such as inserting, updating, and creating tables, as well as utilizing clauses like UNION, INTERSECT, and MINUS to combine query outputs. Additionally, it lists several queries to be answered, demonstrating practical applications of these SQL concepts.

Uploaded by

Priyanshu Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

DBMS Experiment No 8

The document outlines an experiment focused on implementing subqueries in SQL, which are nested queries used within other SQL statements. It explains the usage of subqueries for various commands such as inserting, updating, and creating tables, as well as utilizing clauses like UNION, INTERSECT, and MINUS to combine query outputs. Additionally, it lists several queries to be answered, demonstrating practical applications of these SQL concepts.

Uploaded by

Priyanshu Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY

Experiment no .8

Objective:- To implement the concept of Sub Queries.

Sub Queries:- A Sub Queries is a form of an SQL statement that appears


inside another SQL statement. It also termed as nested Questionry. The
statement containing a Sub Queries called a parent statement. The rows
returned bu the Sub Queries are use by the following statement.
It can be used by the following commands:
1. To insert records in the target table.
2. To create tables and insert records in this table.
3. To update records in the target table.
4. To create view.
5. To provide values for the condition in the WHERE , HAVING IN ,
SELECT,UPDATE, and DELETE statements.

Example: Creating client master table from

oldclient_master, table Create table client_master

AS SELECT * FROM oldclient_master;

Using the Union, Intersect and Minus Clause:

Union Clause:
The user can put together multiple Queries and combine their output using
the union clause . The union clause merges the output of two or more Queries
into a single set of rows and column. The final output of union clause will
be

Output: = Records only in Questionry one + records only in Questionry two


+ A single set of records with is common in the both Queries.

Syntax: SELECT columnname, columname


FROM tablename 1 UNION
SELECT columnname, columnname From tablename2;

Intersect Clause: The use can put together multiple Queries and their output
using the interest clause. The final output of the interest clause will be :
Output =A single set of records which are common in both Queries Syntax:

SELECT columnname, columnname


FROM tablename 1

Harshit Kumar Pandey


2200331550052
RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY

INTERSECT
SELECT
columnname,
columnname FROM
tablename 2;

MINUS CLAUSE:- The user can put together multiple Queries and combine their
output = records only in Questionry one

Syntax: SELECT columnname, columnname FROM tablename MINUS


SELECT columnname,
columnname FROM
tablename ;

Objective: Answer the following Queries:

QUERIES:

1. Find the product_no and description of non- moving products.


2. Find the customer name, address, city and pincode for the client who
has placed order no “019001”
3. Find the client names who have placed order before the month of may
96.
4. Find out if product “1.44 Drive” is ordered by only client and print
the client_no name to whom it was sold.
5. find the names of client who have placed orders worth Rs.10000 or
more.
6. Select the orders placed by ‘Rahul Desai”
7. Select the names of persons who are in Mr. Pradeep’s department and
who have also worked on an inventory control system.
8. Select all the clients and the salesman in the city of Bombay.
9. Select salesman name in “Bombay” who has atleast one client located
at
“Bombay”
Select the product_no, description, qty_on-hand,cost_price of non_moving items in the
product_master table

Harshit Kumar Pandey


2200331550052
RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY

OUTPUT

Harshit Kumar Pandey


2200331550052
RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY

Harshit Kumar Pandey


2200331550052

You might also like