“The computer was born to solve problems that did not exist before.”

Random Posts

Tuesday, December 14, 2021

SQL SELECT Statement

SQL SELECT Statement

In SQL, the SELECT statement is used to query or retrieve data from a table in the database. The returns data is stored in a table, and the result table is known as result-set.

Syntax

  1. SELECT column1, column2, ...  
  2. FROM table_name;  

Here, the expression is the field name of the table that you want to select data from.

Use the following syntax to select all the fields available in the table:

  1. SELECT  *  FROM table_name;  

Example:

EMPLOYEE

EMP_IDEMP_NAMECITYPHONE_NOSALARY
1KristenChicago9737287378150000
2RussellAustin9262738271200000
3AngelinaDenver9232673822600000
4RobertWashington9367238263350000
5ChristianLos angels7253847382260000

To fetch the EMP_ID of all the employees, use the following query:

  1. SELECT EMP_ID FROM EMPLOYEE;  

Output

EMP_ID
1
2
3
4
5

To fetch the EMP_NAME and SALARY, use the following query:

  1. SELECT EMP_NAME, SALARY FROM EMPLOYEE;  
EMP_NAMESALARY
Kristen150000
Russell200000
Angelina600000
Robert350000
Christian260000

To fetch all the fields from the EMPLOYEE table, use the following query:

  1. SELECT * FROM EMPLOYEE  

Output

EMP_IDEMP_NAMECITYPHONE_NOSALARY
1KristenChicago9737287378150000
2RussellAustin9262738271200000
3AngelinaDenver9232673822600000
4RobertWashington9367238263350000
5ChristianLos angels7253847382260000

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages

SoraTemplates

Best Free and Premium Blogger Templates Provider.

Buy This Template