How to update the database?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to update the database?

  1. #1
    Steven Guest

    How to update the database?


    I have two tables:
    emp(employee_no, ename, job, manager_no, hiredate, sal, comm, deptno)
    dept(deptno, dname, location)
    The manager_no is the manager who manage that employee, and manager is also
    a employee in the emp table.

    Q. How can I give all managers a commission(comm) equal to 10% of the sum
    of salaries of employees they directly manage. Update the emp table accordingly.

    Q. How can I add a new column No_Of_Emp to the dept table, and store in it
    the number of employees in the corresponding department by using update.

    Thanks

  2. #2
    Michael Levy Guest

    Re: How to update the database?

    Welcome to the world of hierarchies! SQL (the language) does not handle them
    easily.

    I've got a couple of resources that you should check out:
    Joe Celko's SQL For Smarties book; Ben-Gan had an article in SQL Server Mag.
    that discussed handling hierarchies like this; and David Rozenshtein et al,
    put together a little booked called Tree Processing in SQL.

    -Mike
    --
    Michael Levy MCDBA, MCSD, MCT
    michaell@gasullivan.com



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center