SQL Tutorial SQL Advanced SQL Database SQL References

SQL SELECT Keyword



The SQL SELECT keyword is used to select data from a database table and the selected data is returned in the form of a table.

Syntax

The syntax for using SELECT keyword in different scenarios are given below:

/*select one column*/
SELECT column1 FROM table_name;

/*select multiple columns*/
SELECT column1, column2, ... 
FROM table_name;

/*select all columns of a table*/
SELECT * FROM table_name;

Example:

Consider a database table called Employee with the following records:

EmpIDNameCityAgeSalary
1JohnLondon253000
2MarryNew York242750
3JoParis272800
4KimAmsterdam303100
5RameshNew Delhi283000
6HuangBeijing282800

  • To fetch Name and Salary data of the employees present in the Employee table, the SQL code is:

    SELECT Name, Salary FROM Employee;
    

    This will produce the result as shown below:

    NameSalary
    John3000
    Marry2750
    Jo2800
    Kim3100
    Ramesh3000
    Huang2800
  • To fetch all fields of the Employee table, the SQL code will be:

    SELECT * FROM Employee;
    

    This result of the following code will be:

    EmpIDNameCityAgeSalary
    1JohnLondon253000
    2MarryNew York242750
    3JoParis272800
    4KimAmsterdam303100
    5RameshNew Delhi283000
    6HuangBeijing282800

❮ SQL Keywords