Updating multiple tables in sql
Sybase IQ ignores the ORDER BY clause in searched UPDATE and returns a message that the syntax is not valid ANSI syntax.
If no WHERE clause is specified, every row is updated.
If a column has a DEFAULT value, this DEFAULT value is used as the value of the column in any UPDATE statement that does not explicitly modify the value for the column.
For detailed information on the use of column DEFAULT values, see “Using column defaults” in Chapter 9, “Ensuring Data Integrity” in the System Administration Guide: Volume 1.
We are going to update column DESCRIPTION and PICTURE in table Categories_Test by using data in table Categories, based on data in the common column CATEGORY_ID. Update data in a column in table A based on a common column in table B. Update data in two columns in table A based on a common column in table B. Conditionally update data in table A based on a common column in table B. No portion may be reproduced without my written permission.
The update query below shows that the PICTURE column is updated by looking up the same ID value in CATEGORY_ID column in table Categories_Test and Categories. If you need to update multiple columns simultaneously, use comma to separate each column after the SET keyword. Here we only want to update PICTURE column in Categories_Test table where the data in Category_Name column is Seafood in table Categories. Software and hardware names mentioned on this site are registered trademarks of their respective companies.
The left side of each SET clause must be a column in a base table.
If the update violates any check constraints, the whole statement is rolled back.
Sybase IQ supports scalar subqueries within the SET clause, for example: Sybase IQ supports DEFAULT column values in UPDATE statements.
If the FROM clause specifies a one-to-many join and the SET clause references a cell from the “many” side of the join, the cell is updated from the first value selected.
In other words, if the join condition causes multiple rows of the table to be updated per row ID, the first row returned becomes the update result.