Lesson 8 | Use the SELECT statement |
Objective | Create a SELECT statement to return the city for each of the rows in the customer table. |
CREATE TABLE customer ( CustomerID INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), DOB DATE, City VARCHAR(50) );
INSERT INTO customer (CustomerID, first_name, last_name, DOB, City) VALUES (1, 'Sarah', 'Johnson', '1985-05-12', 'New York'), (2, 'John', 'Miller', '1972-01-30', 'Los Angeles'), (3, 'Emily', 'Williams', '1990-11-07', 'Chicago'), (4, 'David', 'Brown', '1980-08-21', 'Miami'), (5, 'Olivia', 'Davis', '1995-03-16', 'Seattle');
SELECT City FROM customer;
City ------------- New York Los Angeles Chicago Miami Seattle
SELECT what FROM where
SELECT lastname, firstname from Customer
LastName | FirstName |
Sasser | Sheila |
Golden | Debbie |
Schwartz | Kathy |
SELECT * FROM Orders, OrderItems WHERE Orders.OrderId = OrderItems.OrderId