Code Flashcards

1
Q

SELECT

A

SELECT CustomerID, CustomerName, CustomerAddress

FROM Customers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SELECT + WHERE

A

SELECT OrderID, ProductID
FROM Orders
WHERE CustomerID = ‘C1’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

SELECT + JOIN

A

SELECT Customers.CustomerName, Orders.QuantityOrdered, Products.ProductName
FROM Customers JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
JOIN Products
ON Orders.ProductID = Products.ProductID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

VIEW + SELECT + WHERE

A

CREATE VIEW P1Orders AS
SELECT CustomerID, OrderID, Quantity
FROM Orders
WHERE ProductID = “P1”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

VIEW + SELECT + JOIN

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

SELECT + ORDER BY

A

SELECT *
FROM MyTable
ORDER BY MyColumn1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SELECT + MIN

A
SELECT MIN(MyColumn1)
FROM MyTable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

UPDATE + WHERE

A

UPDATE MyTable
SET MyColumn2 = ‘contoso’
WHERE MyColumn1 = 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

DELETE

A

DELETE FROM MyTable

WHERE MyColumn2 = ‘contoso’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

INSERT

A

INSERT INTO MyTable(MyColumn1, MyColumn2, MyColumn3)

VALUES (99, ‘contoso’, ‘hello’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

CREATE TABLE

A
CREATE TABLE MyTable
(
    MyColumn1 INT NOT NULL PRIMARY KEY,
    MyColumn2 VARCHAR(50) NOT NULL,
    MyColumn3 VARCHAR(10) NULL
);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly