SQL Basics

Common SQL commands used to work with data.

Four Common SQL Commands

SQL commands help control what happens inside a database. The four examples below show how to retrieve, add, change, and remove records.

SELECT

The SELECT command retrieves records from a table.

SELECT * FROM customers;

INSERT

The INSERT command adds a new record to a table.

INSERT INTO customers (customer_id, first_name, last_name, city) VALUES (1, 'Sam', 'Johnson', 'Chicago');

UPDATE

The UPDATE command changes information already stored in a table.

UPDATE customers SET city = 'Naperville' WHERE customer_id = 1;

DELETE

The DELETE command removes a record from a table.

DELETE FROM customers WHERE customer_id = 1;

How SQL Supports Real Websites

Website Feature Database Action SQL Example
User login Checks a user record SELECT
New account Adds a user record INSERT
Profile edit Changes saved information UPDATE
Account removal Deletes selected information DELETE