Updating multiple columns of a table tips for online adult dating 2016 2016 edition
clause; columns not explicitly modified retain their previous values.
There are two ways to modify a table using information contained in other tables in the database: using sub-selects, or specifying additional tables in the you should ensure that the join produces at most one output row for each row to be modified.
Because of the restriction on the CATGROUP column, only one row qualifies for the update (although four rows qualify for the join).
update category set catid=100 from event where event.catid=category.catid and catgroup='Concerts'; select * from category where catid=100; catid | catgroup | catname | catdesc ------- ---------- --------- --------------------------------- 100 | Concerts | Pop | All rock and pop music concerts (1 row) The advantage to this approach is that the join criteria are clearly separated from any other criteria that qualify rows for the update.
This can also be used to change the column to NULL if the column has no default and is defined to allow null values.
Compound assignment operator: = Add and assign -= Subtract and assign *= Multiply and assign /= Divide and assign %= Modulo and assign &= Bitwise AND and assign ^= Bitwise XOR and assign |= Bitwise OR and assign Returns updated data or expressions based on it as part of the UPDATE operation.
The columns that are not on the list retain their original values.If the item already exists, instead update the stock count of the existing item.