SQL Select Statement

The SQL SELECT statement is used to retrieve records from one or more tables in your SQL database.

 

The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set.

 

SQL Select Statement’s  Syntax

SELECT column_name,column_name FROM table_name;

SELECT identifies the columns to be displayed.

FROM identifies the table containing those columns.

 

SELECT ALL FIELDS FROM ONE TABLE

Select * from employees;

It will display all data of employees table. We use asterisk keyword (*) to access the whole data from the table.

 

SELECT INDIVIDUAL FIELDS FROM ONE TABLE

You can also use the SQL SELECT statement to select individual fields from the table, as opposed to all fields from the table.

Select emp_id, first_name, salary from employees;

This SQL SELECT example would return only the emp_id, first_name, and salary fields from the employee’s table.

 

How to write SQL SELECT statements

  • The select statement is not case-sensitive.

  • SELECT statement can be on one or more lines.

  • Keywords can’t be abbreviated or split across lines.

  • SQL statement must be terminated by semicolon (;)

 

You have seen the syntax and Application of SQL Select Statement. That’s all, SQL select statement is the only way to retrieve the data from SQL base Database.

0 Comment

Leave a Reply