From 0c425af9387cf210b1499a9450bf754ae7268364 Mon Sep 17 00:00:00 2001 From: fede Date: Mon, 12 May 2025 14:23:22 -0300 Subject: [PATCH] resumida clase 3 --- BasesDeDatos/resumen1.org | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/BasesDeDatos/resumen1.org b/BasesDeDatos/resumen1.org index 3c54b78..4d99785 100644 --- a/BasesDeDatos/resumen1.org +++ b/BasesDeDatos/resumen1.org @@ -43,3 +43,41 @@ FROM ( ) AS d GROUP BY d.DepartamentoId; #+end_src + +* clase3 Subconsulta con update, insert, delete + +** insert +#+begin_src sql +INSERT INTO Customers + (CustomerID, + CompanyName, + ContactName, + ContactTitle, + Address, City, Region, PostalCode, Country, Phone, Fax) +SELECT + SUBSTRING(firstname, 1, 3) + SUBSTRING(lastname, 1, 2) AS CustomerID, + lastname AS CompanyName, + firstname AS ContactName, + title AS ContactTitle, + address, city, region, postalcode, country, homephone AS Phone, NULL AS Fax +FROM Employees; +#+end_src +** update +#+begin_src sql +DELETE FROM [Order Details] +WHERE OrderID IN ( + SELECT OrderID + FROM Orders + WHERE OrderDate = '2005-04-14' +); +#+end_src +** delete +#+begin_src sql +UPDATE Products +SET UnitPrice = UnitPrice + 2 +WHERE SupplierID IN ( + SELECT SupplierID + FROM Suppliers + WHERE Country = 'USA' +); +#+end_src