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?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework