SQL SELECT
Summary: In this tutorial, you will learn how to use SQL SELECT statement to retrieve data from a database table.
The SQL SELECT statement allows you to retrieve the data from one or more database table. Here is the common syntax of the SQL SELECT statement:
SELECT column_list
FROM table_list
WHERE row_conditions
GROUP BY column_list
HAVING group_conditions
ORDER BY sort_list ASC | DESC
First you have to specify the table name that you want to retrieve the data. The table name is followed by the keyword FROM. Second you have to indicate what data in want to retrieve. You can list the specify the column of the database table after the keyword SELECT. Suppose you want to retrieve last name of employees in the employees table, you can perform the following query:
SELECT lastname
FROM employees
The query fetches the values from the column lastname in all rows in the employees table and returns the result below.

You can also use SQL SELECT statement to retrieve multiple columns from a database table. In order to do so you must provide a comma between columns in the column list. For example, if you want to retrieve first name, last name and title of all employees, you can execute the following query:
SELECT lastname, firstname, title
FROM employees

To retrieve all information of employee in the employees table, you can list all columns name and separate them by commas. In case a database table having many columns and you do not want to list them all after the keyword SELECT, you can use an asterisk (*) to indicate that you want to retrieve all columns without explicitly specifying them in the column list. For instance, the following query allows you to retrieve all employee's information by using the asterisk (*):
SELECT *
FROM employees

In this tutorial, you’ve learned how to use simple SQL SELECT statement to retrieve data from a table. You’ve also learned how to select a single column, multiple columns by separating them with a comma, and all columns by using the asterisk (*) from a table.
Related Tutorials