Sub query in the update command, Database Management System

Sub query in the UPDATE command:

Example:  //Double  the  commission  for  employees,  who  have  got  at  least  2 increments.

UPDATE EMP

SET COMM = COMM * 2

WHERE 2 <= (   SELECT COUNT (*) FROM INCR WHERE INCR.EMPNO = EMP.EMPNO

GROUP BY EMPNO);

Be advised that the use of subquery that counts the number of increments given to every employee stored in the INCR table. Please note the comparison, instead of ......>=2, we have written reverse of it as 2 <= .....

DELETE Command

In the following example, the deletion will be performed in EMP table.No deletion will be performed in the INCR table.

Example: Delete the records of employees who have got no increment.

DELETE FROM EMP

WHERE EMPNO NOT IN (SELECT EMPNO FROM INCR);

Posted Date: 3/11/2013 1:11:58 AM | Location : United States







Related Discussions:- Sub query in the update command, Assignment Help, Ask Question on Sub query in the update command, Get Answer, Expert's Help, Sub query in the update command Discussions

Write discussion on Sub query in the update command
Your posts are moderated
Related Questions
Which is a legal expression in SQL? SELECT NAME FROM EMPLOYEE is a legal expression in SQL.

How can one distinguish among different kinds of parameters? Input parameters are used to pass data to subroutines. Output parameters are used to pass data from subrout

what is view?explain


Define the Canonical cover Ans: A canonical cover F c for F is a set of dependencies like F logically implies all dependencies in F c , and F c logically entails all dependen

For every n-ary relationship type R where n>2, we make a new table S to represent R. We contain as foreign key attributes in s the primary keys of the relations that show the parti


Define the basic operations of the relational algebra?     Ans: Basic operators of relational algebra are: 1. Union (∪) - Selects tuples which are in either P or Q or in bot

Normal 0 false false false EN-US X-NONE X-NONE

Relational Model: The relational model uses a collection of tables to represent both data and the relationships among those data. Each table has multiple columns and each column h