java2db

SELECT statement to get records from the table in sql



SELECT statement is used  select the data of a specific column/columns or entire record/records from the table.The result is stored in a result table,called the result-set.

 

Example table  (EMP_DETAILS) :

E_NO
E_NAME
E_GENDER
E_SALARY
E_ADDRESS
E_JOIN_DATE
E_IN_TIME
1 Rose S F 10000 street10,xxx,UK 03-MAR-13 10-MAR-13 12.10.10.0
2 Tom M 15000 street11,xxx,UK 04-MAY-13 12-MAY-13 12.09.10.0
3 Jerry F 13000 street122,xxx,UK 05-JAN-13 15-JAN-13 12.10.10.0
4 Alex M 12000 street13,xxx,UK 03-DEC-12 23-DEC-12 12.08.10.0

 

Syntax:

SELECT  column_1 , column_2,..  FROM <table_name> WHERE <condition> ;//for specific columns
&
SELECT FROM <table_name> WHERE <condition> ; //for all columns

 

SELECT statement SELECT statement for particular columns :

E_NO
E_NAME
E_SALARY
E_JOIN_DATE
1 Rose S 10000 03-MAR-13
3 Jerry 13000 05-JAN-13
4 Alex 12000 03-DEC-12

 

SELECT statement SELECT statement for all columns :

E_NO
E_NAME
E_GENDER
E_SALARY
E_ADDRESS
E_JOIN_DATE
E_IN_TIME
1 Rose S F 10000 street10,xxx,UK 03-MAR-13 10-MAR-13 12.10.10.0
3 Jerry F 13000 street122,xxx,UK 05-JAN-13 15-JAN-13 12.10.10.0
4 Alex M 12000 street13,xxx,UK 03-DEC-12 23-DEC-12 12.08.10.0

 

SELECT statementSelect the entire table :

The above sql statement returns entire table data as follows.

E_NO
E_NAME
E_GENDER
E_SALARY
E_ADDRESS
E_JOIN_DATE
E_IN_TIME
1 Rose S F 10000 street10,xxx,UK 03-MAR-13 10-MAR-13 12.10.10.0
2 Tom M 15000 street11,xxx,UK 04-MAY-13 12-MAY-13 12.09.10.0
3 Jerry F 13000 street122,xxx,UK 05-JAN-13 15-JAN-13 12.10.10.0
4 Alex M 12000 street13,xxx,UK 03-DEC-12 23-DEC-12 12.08.10.0



Related Posts :
Sql FOREIGN KEY constraint on table column
Sql CHECK constraint on table column
Sql NOT NULL constraint on table column
Sql UNIQUE constraint on table column
Sql PRIMARY KEY constraint on table column
Sql full outer join on tables with an example
Sql right outer join on tables with an example
Sql left outer join on tables with an example
   [will not be published]



^ <