SQL SELECT Statement
The SQL SELECT Statement
The SELECT statement is used to select data from a database.
ExampleGet your own SQL Server
Return data from the Customers table:
SELECT CustomerName, City FROM Customers;
Syntax
SELECT column1, column2, ...
FROM table_name;
Here, column1, column2, ... are the field names of the table you want to select data
from.
The table_name represents the name of the table you want to select data from.
Demo Database
Below is a selection from the Customers table used in the examples:
CustomerI CustomerNam ContactNam PostalCod
Address City Country
D e e e
Alfreds German
1 Maria Anders Obere Str. 57 Berlin 12209
Futterkiste y
Ana Trujillo Avda. de la
México
2 Emparedados y Ana Trujillo Constitución 05021 Mexico
D.F.
helados 2222
Antonio Moreno Antonio Mataderos México
3 05023 Mexico
Taquería Moreno 2312 D.F.
Around the Thomas 120 Hanover Londo
4 WA1 1DP UK
Horn Hardy Sq. n
Berglunds Christina Berguvsväge
5 Luleå S-958 22 Sweden
snabbköp Berglund n8
ADVERTISEMENT
REMOVE ADS
Select ALL columns
If you want to return all columns, without specifying every column name, you can use
the SELECT * syntax:
Example
Return all the columns from the Customers table:
SELECT * FROM Customers;
Exercise?
What is the purpose of the SQL SELECT statement?
To insert data into a database
To select data from a database
To delete data from a database
To update data in a database
Video: SQL SELECT Statement
ADVERTISEMENT
COLOR PICKER
ADVERTISEMENT
REMOVE ADS
ADVERTISEMENT
ADVERTISEMENT
PLUS
SPACES
GET CERTIFIED
FOR TEACHERS
FOR BUSINESS
CONTACT US