SQL SELECT Statement

How do I get data from a database?

The SELECT statement retrieves data from a database.
The data is returned in a table-like structure called a result-set.
SELECT is the most frequently used action on a database.

The SQL SELECT syntax

The general syntax is

SELECT column-names
  FROM table-name

To select all columns use *

SELECT *
  FROM table-name

CUSTOMER
Id
FirstName
LastName
City
Country
Phone

SQL SELECT Examples

Problem: List all customers
SELECT *
  FROM Customer
Result:  91 records
Id FirstName LastName City Country Phone
1 Maria Anders Berlin Germany 030-0074321
2 Ana Trujillo México D.F. Mexico (5) 555-4729
3 Antonio Moreno México D.F. Mexico (5) 555-3932
4 Thomas Hardy London UK (171) 555-7788
5 Christina Berglund Luleå Sweden 0921-12 34 65

CUSTOMER
Id
FirstName
LastName
City
Country
Phone
Problem: List the first name, last name, and city of all customers
SELECT FirstName, LastName, City
  FROM Customer
Result:  91 records
FirstName LastName City
Maria Anders Berlin
Ana Trujillo México D.F.
Antonio Moreno México D.F.
Thomas Hardy London
Christina Berglund Luleå


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