There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Wed Apr 3, 2024
Definition:
Although joins are commonly used for retrieving data from multiple tables, they can also be utilized for updating and deleting data across multiple tables. It refers to the process of modifying or removing data from multiple tables in a database simultaneously, by using a join operation to link the tables based on a common column or set of columns.
When updating with join, the data in one table is modified based on the matching data in another table. For example, you can update a customer’s information in one table and their order history in another table simultaneously using a join.
When deleting with join, the data in one or more tables is removed based on the matching data in another table. For instance, you can delete a customer’s information from one table and their associated orders from another table simultaneously using a join.
Tables used in below examples
Here are the two tables that we will be utilizing to carry out update and delete operations with joins.
CREATE TABLE Sales.Targets (
Target_Id INT PRIMARY KEY,
Percentage DECIMAL(4, 2) NOT NULL DEFAULT 0.00
);
INSERT INTO Sales.targets(
Target_Id,
Percentage
)
VALUES
(1, 0.2),
(2, 0.3),
(3, 0.5),
(4, 0.6),
(5, 0.8); .
INSERT INTO Sales.commissions (
VALUES
Benefits of using update & delete with joins Using join statements to update and delete data in a relational database can offer several benefits:
Vijay Kashyap
Learn SQL in simplied manner