Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The problem about Relational Database

Status
Not open for further replies.

tzungshianlin

Programmer
Dec 18, 2014
2
0
0
TW
There are two tables:
Investigator (INO, Name, Salary, DNO)
Department (Dnumber, Dname)

They represent for:
Investigator (The identification number for investigator, The name for investigator, Salary, The number for department)
Department (The number for department, The name for department)

The question:
Please write down the SQL:
Focusing on "special" department employee whose salary is less than 30000, and adding additional 5% salary.

The answer is:
UPDATE Investigator
SET Salary= Salary*1.05
WHERE EXISTS(
SELECT*
FROM DEPARTMENT
WHERE Department.Dnumber= Investigator.DNO
AND Dname='special' AND Salary<30000

I can't understand this sentence:
WHERE Department.Dnumber= Investigator.DNO
Can anyone please tell me?
Thanks
 
This appears to be a school assignment.

Read the RED sentence at the bottom of this page and read the posting guidelines.

Schoolwork is NOT ALLOWED on these forums.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
the clause: WHERE Department.Dnumber= Investigator.DNO
is one of the constraints on the query that begins with the word SELECT

The three constraints following the WHERE clause are used to define the subset of records that will be affected by the UPDATE statement.

The query can be rewritten with an inner join instead of the "WHERE Department.Dnumber= Investigator.DNO" part of the WHERE clause:

UPDATE Investigator
SET Salary= Salary*1.05
WHERE Dname='special' AND Salary<30000
INNER JOIN Department ON
Department.Dnumber= Investigator.DNO


==================================
adaptive uber info galaxies (bigger, better, faster than agile big data clouds)


 
Sorry, this is the question in uni but I will not post next time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top