In this tutorial I will explain what a SQL SELECT statement is, when can you use it and I will give code examples how to use it.
A database stores data in tables. Data in tables is stored using columns and rows. You can retrieve data from tables using SQL SELECT Statement.
SELECT can be used to:
- Retrieve data from specific columns which exist in one or more tables.
- Create calculated fields that contains specific logic to product new results and return it to the user as extra column.
- Use Manipulation Functions (Text, Data and Time, Numeric). For instance retrieve on the fly today’s date.
- Use aggregate functions to summary the rows. For instance Sum sales for each country.
- Limit Results. For instance show only top 10 customers.
- Retrieve only distinct rows. For instance to get only a list of values that are used in a specific field.
In this tutorial we will cover the first two examples and the rest will be covered in separate tutorials that we will add to our SQL Tutorial page.
SQL Syntax and examples
Below is a very simple SQL SELECT syntax:
To get full access to this page
SELECT FieldName1, FieldName2, FieldName3
I would like to show you now a few simple examples using Select.My table is called PersonDetails and contains only three fields (PersonID, PersonFirstName, PersonSurname). Based on this table I will present you how to retrieve only the fields you need and retrieve ALL rows from the table which is 4 in this case.
Become a member or Sign in
Membership is just $3.99/month