Code Flashcards
SELECT
SELECT CustomerID, CustomerName, CustomerAddress
FROM Customers
SELECT + WHERE
SELECT OrderID, ProductID
FROM Orders
WHERE CustomerID = ‘C1’
SELECT + JOIN
SELECT Customers.CustomerName, Orders.QuantityOrdered, Products.ProductName
FROM Customers JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
JOIN Products
ON Orders.ProductID = Products.ProductID
VIEW + SELECT + WHERE
CREATE VIEW P1Orders AS
SELECT CustomerID, OrderID, Quantity
FROM Orders
WHERE ProductID = “P1”
VIEW + SELECT + JOIN
CREATE VIEW CustomersProducts AS
SELECT Customers.CustomerName, Orders.QuantityOrdered, Products.ProductName
FROM Customers JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
JOIN Products
ON Orders.ProductID = Products.ProductID
SELECT + ORDER BY
SELECT *
FROM MyTable
ORDER BY MyColumn1
SELECT + MIN
SELECT MIN(MyColumn1) FROM MyTable
UPDATE + WHERE
UPDATE MyTable
SET MyColumn2 = ‘contoso’
WHERE MyColumn1 = 3
DELETE
DELETE FROM MyTable
WHERE MyColumn2 = ‘contoso’
INSERT
INSERT INTO MyTable(MyColumn1, MyColumn2, MyColumn3)
VALUES (99, ‘contoso’, ‘hello’)
CREATE TABLE
CREATE TABLE MyTable ( MyColumn1 INT NOT NULL PRIMARY KEY, MyColumn2 VARCHAR(50) NOT NULL, MyColumn3 VARCHAR(10) NULL );