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

PostgreSQL Update Table: Change the value of more than one column with user defined content


3. Write a SQL statement to change the email and commission_pct column of the employees table with 'not available' and 0.10 for those employees whose department_id is 110.

Sample table: employees


Sample Solution:

Code:

UPDATE employees 
SET email='not available',
commission_pct=0.10 
WHERE department_id=110;

Output:

See the result. Only two rows have been updated.

postgres=# SELECT *
postgres-# FROM employees
postgres-# WHERE department_id=110
postgres-# AND  email='not available';
 employee_id | first_name | last_name |     email     | phone_number | hire_date  |   job_id   |  salary  | commission_pct | manager_id | department_id
-------------+------------+-----------+---------------+--------------+------------+------------+----------+----------------+------------+---------------
         205 | Shelley    | Higgins   | not available | 515.123.8080 | 1987-09-30 | AC_MGR     | 12000.00 |           0.10 |        101 |           110
         206 | William    | Gietz     | not available | 515.123.8181 | 1987-10-01 | AC_ACCOUNT |  8300.00 |           0.10 |        205 |           110
(2 rows)

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

Previous: Write a SQL statement to change the email and commission_pct column of the employees table with 'not available' and 0.10 for all employees.
Next: Write a SQL statement to change the email column of employees table with 'not available' for those employees whose department_id is 80 and gets a commission is less than.20%.

What is the difficulty level of this exercise?