UPDATE statement as there are significant processing differences from SQL Server. When you rewrite the statement to use a correlated subquery, such as in the following example, if more than one value is returned from the sub query, a SQL error will be raised: SQL Error : Subquery returns more than 1 row.Ĭonsult the documentation for the Aurora MySQL In the current implementation, the SQL Server engine silently chooses an arbitrary value if more than one value exists for the same row.
When rewriting UPDATE FROM queries, include a WHERE clause to limit which rows are updated even if the SQL Server version (where the rows were limited by the join condition) did not have one.įor DELETE statements, the workaround is simple and, in most cases, easier to read and understand.įor UPDATE statements, the workaround involves repeating the correlated subquery for each column being set.Īlthough this approach makes the code longer and harder to read, it does solve the logical challenges associated with updates having multiple matched rows in the joined tables. You can easily rewrite the DELETE and UPDATE FROM statements as subqueries.įor DELETE, place the subqueries in the WHERE clause.įor UPDATE, place the subqueries either in the WHERE or SET clause. MySQL UsageĪmazon Aurora MySQL-Compatible Edition (Aurora MySQL) doesn’t support DELETE and UPDATE FROM syntax. Customer OrderDateįor more information, see UPDATE (Transact-SQL), DELETE (Transact-SQL), and FROM clause plus JOIN, APPLY, PIVOT (Transact-SQL) in the SQL Server documentation. CREATE TABLE OrderCorrectionsįor the preceding example, the result looks as shown following. Update multiple columns in Orders based on the values in OrderCorrections. (2, 'Jack', '20180402') DELETE FROM Customersįor the preceding examples, the result looks as shown following. ) INSERT INTO Orders (OrderID, Customer, OrderDate) Syntax UPDATE ĭelete customers with no orders. The current implementation chooses an arbitrary value from the set of potential values and is non deterministic. However, these statements can introduce logical inconsistencies if a row in an updated table is matched to more than one row in a joined table. For UPDATE, you can use this syntax to set multiple column values simultaneously without repeating the subquery for every column. This functionality is similar to using a WHERE clause with a derived table subquery. You can use this additional FROM clause to limit the number of modified rows by joining the table being updated, or deleted from, to one or more other tables.
SQL Server supports an extension to the ANSI standard that allows using an additional FROM clause in UPDATE and DELETE statements.