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

Explain ODBC? ODBC - Open DataBase Connectivity (ODBC) enable the integration of SQL along with a general-reasons programming language.

What is substitutability? Any method of a class-say A can equally well be adjured with any object belonging to any subclasses B of A. This characteristic leads to code reuse, a

What is Trigger? Trigger: A database trigger is procedural code which is automatically executed in response to specific events on a particular table in a database. Triggers can

What is Nested Queries explain in details? Nested Queries - A SELECT query could have subquery(s) in it. While a SELECT query having another SELECT query in it, is known as n

Describe the various types of Online Analytical Processing (OLAP) tools and briefly discuss how the support common analytical operations.

Describe a technique for direct search? Explain how data is stored within a file so which direct searching can be performed. For a file of unordered fixed length records by u

Which method is used to key transformation ? A hash method is used to key transformation.

Timestamps For Read operations: If TS (T) If TS (T) >= W-timestamp (Q), then the transaction T is trying to read a value of data item Q which has been written and committed

Cyber Transit Ltd keeps up-to-date information on the processing and current position of each dispatched item. Dispatched items are the main concern of the Cyber Transit product tr