SQL Syntax

What does a SQL statement look like?

  • 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.
  • By the way, the syntax of a language describes the language elements.

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. SELECT  -- Read the data
  2. INSERT  -- Insert new data
  3. UPDATE  -- Update existing data
  4. DELETE  -- Remove data

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'
 ORDER BY LastName

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'

Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas