Αποτελέσματα Αναζήτησης
If you want to update specific rows (ie where the IDs match) you probably want to do a coordinated subquery. However, since you are using Oracle, it might be easier to create a materialized view for your query table and let Oracle's transaction mechanism handle the details.
6 Δεκ 2017 · Learn about several methods to update data using subqueries in UPDATE statements to make them more effective and easier to maintain in Oracle SQL.
Subquery Method. The first option is to do an update of the DEST_TAB table using a subquery to pull the correct data from the SOURCE_TAB table. Notice the EXISTS predicate to exclude rows from the DEST_TAB table with no matching row in the SOURCE_TAB table.
A subquery is a SELECT statement nested inside another statement such as SELECT, INSERT, UPDATE, or DELETE. Typically, you can use a subquery anywhere that you use an expression. Consider this following subquery example that uses the products table from the sample database.
Then I want UPDATE values in another table based on this result: UPDATE table2 SET Name = table1.Name WHERE ID = table1.ID. As I understood, I can only do internal select in one place, like: UPDATE table2 SET Name = (select Name from table1) WHERE ... And I don't know how to specify WHERE-condition.
4 Αυγ 2024 · Ever found yourself needing to update a bunch of rows in your database, but the condition for the update depends on data from another table? That’s where UPDATE with a subquery comes in handy. Let’s break it down.
update Taxonomy set sourceId = ( select id from TaxonomyMapping a where a.oldId = ( select cm.en_ID from TaxonomyMapping ta join CategoryMapping cm on ta.oldId = cm.language_ID where ta.oldId = oldId limit 1 ) ) where id > -1; The tables are as following: Taxonomy(id, oldId, sourceId, name, language)