·  SQL UPDATE

 

- Info:

  - UPDATE statement is used to update values of already existing one or more records of single table.

  - WHERE clause defines records which should be updated.

  - String values should be enclosed into single qoutes.

    If inserted value should contain single qoute escape it with another single qoute: 'It''s all right'.

 

- Update specific records:

  UPDATE PEOPLE

  SET    AGE    = AGE+1,

         WEIGHT = 120

  WHERE  NAME   = 'Ivor';

 

- Use subqueries to define values and filtering criteria:

  UPDATE PEOPLE

  SET    WEIGHT = (SELECT WEIGHT

                   FROM   EMPLOYEES

                   WHERE  EMPLOYEE_ID = 20)

  WHERE  NAME   = 'Ivor';