SQL Syntax

  • The syntax of a language describes the language elements.
  • SQL statements are somewhat like simple English sentences.
  • Keywords include SELECT, UPDATE, WHERE, ORDER BY, etc.
  • ANSI Standard SQL is the lingua franca for relational databases.
The definitive guide
for data professionals

Order today!
 See 2 min video

The SQL Syntax

SQL was designed to be entered on a console and results would display back to a screen.

Today, SQL is mostly used by programmers who use SQL inside their language to build applications that access data in a database.

Four fundamental operations that apply to any database are:

  1. Read the data  --  SELECT
  2. Insert new data  --  INSERT
  3. Update existing data  --  UPDATE
  4. Remove data  --  DELETE

Collectively these are referred to as CRUD (Create, Read, Update, Delete).

The general form for each of these 4 operations in SQL is presented next.

The SQL SELECT general form

SELECT column-names
FROM table-name
WHERE condition
ORDER BY sort-order

SELECT FirstName, LastName, City, Country 
FROM Customer
WHERE City = 'Paris'

The SQL INSERT general form

INSERT table-name (column-names)
VALUES (column-values)

INSERT Supplier (Name, ContactName, City, Country)
VALUES ('Oxford Trading', 'Ian Smith', 'Oxford', 'UK')

The SQL UPDATE general form

UPDATE table-name
SET column-name = column-value
WHERE condition

UPDATE OrderItem
SET Quantity = 2
WHERE Id = 388

The SQL DELETE general form

DELETE table-name
WHERE condition

DELETE Customer
WHERE Email = 'alex@gmail.com'