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
sql is relationally complete-justify

tell me the functionality,advantages and disadvantages of student database

A use case diagram giving a pictorial overview of user requirements and brief use case descriptions. As the case study contains only an outline of a business scenario, you will als

In an E-R diagram how attributes are represented ? In an E-R diagram attributes are represented in a ellipse.

Difference between SQL and SQL*Plus SQL SQL*Plus SQL is a language SQL *Plus is an environment It   is   bas

Domain Constraints Domain constraints are primarily formed for defining the logically correct values for an attribute of a relation. The relation allows attributes of a relatio

Discuss how the bi-directional Implementations are made. In bi-directional implementation of the association, a pair of references must implement every link. The declarations a

When is UPDATE_STATISTICS command used? - When processing of large data is done, this command is used. - Whenever large number of modification, deletions or copy takes place

Describe the algorithm for updating indices for a single level index when a record is    (i) Inserted  (ii)  deleted What will be the modification if there are multilevel in

Create centralized relational database using bottom up method.   (a) Recognize a single un-normalized relation for the above scenario.          (b) Recognize the primary key for