Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL Update Table Statement Exercises: Change salary of employee to 8000 whose ID is 105, if the existing salary is less than 5000

MySQL Update Table Statement: Exercise-6 with Solution

Write a SQL statement to change salary of employee to 8000 whose ID is 105, if the existing salary is less than 5000.

Here is the sample table employees.


UPDATE employees SET SALARY = 8000 WHERE employee_id = 105 AND salary < 5000;

Let execute the above code in MySQL 5.6 command prompt

See the result. Only the effected rows have been displayed.

+-------------+------------+-----------+---------+--------------+------------+---------+---------+----------------+------------+---------------+
| EMPLOYEE_ID | FIRST_NAME | LAST_NAME | EMAIL   | PHONE_NUMBER | HIRE_DATE  | JOB_ID  | SALARY  | COMMISSION_PCT | MANAGER_ID | DEPARTMENT_ID |
+-------------+------------+-----------+---------+--------------+------------+---------+---------+----------------+------------+---------------+
|         105 | David      | Austin    | DAUSTIN | 590.423.4569 | 1987-06-22 | IT_PROG | 8000.00 |           0.00 |        103 |            60 |
+-------------+------------+-----------+---------+--------------+------------+---------+---------+----------------+------------+---------------+


Have another way to solve this solution? Contribute your code (and comments) through Disqus.


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a SQL statement to change the email column of employees table with 'not available' for those employees who belongs to the 'Accounting' department.
Next: Write a SQL statement to change job ID of employee which ID is 118, to SH_CLERK if the employee belongs to department, which ID is 30 and the existing job ID does not start with SH.

What is the difficulty level of this exercise?