Session 13 SQL Activities
This page lists the SQL statements completed for the Session 13 activities. The examples include single-table SELECT statements and data modification statements using INSERT, UPDATE, and DELETE.
Single-Table SELECT Statements
The following SQL statements retrieve data from one table. These statements show how SELECT queries can return all columns, specific columns, filtered rows, sorted results, and calculated results.
SELECT * FROM CUSTOMERS;SELECT CustomerName, City FROM CUSTOMERS;SELECT * FROM CUSTOMERS WHERE City = 'Chicago';SELECT * FROM CUSTOMERS WHERE State = 'IL';SELECT * FROM CUSTOMERS ORDER BY CustomerName ASC;SELECT * FROM CUSTOMERS WHERE CustomerID = 1;SELECT COUNT(*) FROM CUSTOMERS;SELECT DISTINCT City FROM CUSTOMERS;
INSERT, UPDATE, and DELETE Statements
The following SQL statements change data in a table. The INSERT statement adds a new record, the UPDATE statement changes an existing record, and the DELETE statement removes a record.
INSERT INTO CUSTOMERS (CustomerID, CustomerName, City, State) VALUES (6, 'Sam Johnson', 'Chicago', 'IL');UPDATE CUSTOMERS SET City = 'Naperville' WHERE CustomerID = 6;DELETE FROM CUSTOMERS WHERE CustomerID = 6;
Reflection
While completing these activities, I learned how SQL statements help organize, search, and change information in a database. SELECT statements help find specific records, while INSERT, UPDATE, and DELETE statements help manage the data stored in a table. I can apply this knowledge in future school, work, or personal projects where I need to store customer information, track inventory, organize website data, or manage records in a clear and accurate way.