Skip to main content

SQL Select Statement

The SQL Select Statement.
                                           Select SQL statement is used to retrieve data from the database table. Select is type of data query language. The result of statement is table like format called ResultSet.

SELECT Syntax:
      •  SELECT Column-Names FROM table_name;
      •  SELECT * FROM table-name;
 Where Column_name are name of fields in tables and * means to retrieve all fields in given table.
Examples Table:
Employee :
 id     Emp_name      Age         Salary
 1 Jebas  35 40,000
 2             Thomas  30 80,000
 3 Mark              25 40,000
 4         Harry  42 50,000
 5 William      45 100,000

Where Id,Emp_name, Age and Salary are Column-names.

Example SELECT Query:
                                           SELECT ID, EMP_name, Salary FROM Employee;

 id     Emp_name     Salary
 1 Jebas 40,000
 2             Thomas 80,000
 3 Mark             40,000
 4         Harry 50,000
 5 William     100,000

This query return only three column ID, Emp_name and Salary as specified in select Statement.

                                        SELECT * FROM EMPLOYEE;

 id     Emp_name      Age         Salary
 1 Jebas  35 40,000
 2             Thomas  30 80,000
 3 Mark              25 40,000
 4         Harry  42 50,000
 5 William      45 100,000

This query return all columns as we specified *;

                                        SELECT ID FROM EMPLOYEE;
 id    
 1
 2            
 3
 4        
 5
It return only one column ID.


Thank You. Like Share and Subscribe 👍 folowlect.com

Comments