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
Create student database and retrieve course name taught by king? STUDENT (name, student#, class, major) COURSE (course name, course#, credit hours, department) SECTION (secti

Distributed Control and Data sharing: The geographical distribution of an organization can be showed in the distribution of the data; if a number of different sites are linked to e

#question.what is mapping constraints and types?.

explain concept of decomposition?

What is banker's algorithm?  Banker's algorithm is a deadlock avoidance algorithm that is applicable to a resource-allocation system with multiple instances of each resource ty

File Manager File manager handles the allocation of space on disk storage. It starts and maintains the list of structures and indices described in the internal schema that is

You are required to write a report which evaluates two of the following issues in relation to your case study database: a. Security issues b. Performance issues c. Backup

Have a look around the site, and at some of the sites they have featured. These are all examples of bad design, and also offer an explanation about why they fall into this category

The Locking Protocol: To manage concurrency related problems we use locking. A lock is mainly a variable that is associated with a data item in the database. A lock can be located

What is the main difference between read-only and update methods? A read-only method does not affect the values of a variable in an object, whereas an update method may alter t