The SELECT Clause
In this lesson, we will take a look at the SELECT statement.
We'll cover the following
The SELECT clause
The SQL SELECT statement is used to fetch the data from a database table that returns this data in the form of a result table. These result tables are called result-sets.
Syntax
The basic syntax of the SELECT
statement is as follows:
SELECT column1, column2, ... columnN FROM table_name;
Here, SELECT
specifies the column1, column2… to be selected and the FROM
clause specifies from which table these columns are to be selected.
If you want to fetch all the fields available in the table, then you can use the following syntax:
SELECT * FROM table_name;
Example
Consider the CUSTOMERS table we used in the last lesson:
ID | NAME | AGE | ADDRESS | SALARY |
---|---|---|---|---|
1 | Mark | 32 | Texas | 50000.00 |
2 | John | 25 | NY | 65000.00 |
3 | Emily | 23 | Ohio | 20000.00 |
4 | Bill | 25 | Chicago | 75000.00 |
5 | Tom | 27 | Washington | 35000.00 |
6 | Jane | 22 | Texas | 45000.00 |
Get hands-on with 1400+ tech skills courses.