The SQL SELECT statement is used to select data
from a database.
Syntax:
Basic syntax of SELECT statement is as follows:
SQL SELECT syntax:
SELECT column_name, column_name
FROM table_name;
Example:
Below is the
"EMPLOYEE1" table:
ID
|
NAME
|
START_DATE
|
END_DATE
|
SALARY
|
CITY
|
1
|
A
|
01/01/2016
00:00:00
|
01/06/2016
00:00:00
|
10,000
|
CHENNAI
|
2
|
B
|
02/01/2016
00:00:00
|
07/03/2016
00:00:00
|
10,000
|
BOMBAY
|
3
|
C
|
03/01/2016
00:00:00
|
08/06/2016
00:00:00
|
10,000
|
DELHI
|
4
|
D
|
01/01/2016
00:00:00
|
07/06/2016
00:00:00
|
10,000
|
PUNE
|
5
|
E
|
01/01/2016
00:00:00
|
09/06/2016
00:00:00
|
10,000
|
NOIDA
|
6
|
F
|
01/01/2016
00:00:00
|
08/06/2016
00:00:00
|
10,000
|
BHUBANESWAR
|
7
|
G
|
01/01/2016
00:00:00
|
07/06/2016
00:00:00
|
10,000
|
HYDERABAD
|
8
|
H
|
01/01/2016
00:00:00
|
06/06/2016
00:00:00
|
10,000
|
KOLKATA
|
1)select ID,
NAME AND SALARY columns from the " EMPLOYEE1" table:
SELECT ID, NAME,
SALARY FROM EMPLOYEE1;
ID
|
NAME
|
SALARY
|
1
|
A
|
10,000
|
2
|
B
|
10,000
|
3
|
C
|
10,000
|
4
|
D
|
10,000
|
5
|
E
|
10,000
|
6
|
F
|
10,000
|
7
|
G
|
10,000
|
8
|
H
|
10,000
|
2) select all
the columns from the " EMPLOYEE1" table:
SELECT * FROM
EMPLOYEE1;
ID
|
NAME
|
START_DATE
|
END_DATE
|
SALARY
|
CITY
|
1
|
A
|
01/01/2016
00:00:00
|
01/06/2016
00:00:00
|
10,000
|
CHENNAI
|
2
|
B
|
02/01/2016
00:00:00
|
07/03/2016
00:00:00
|
10,000
|
BOMBAY
|
3
|
C
|
03/01/2016
00:00:00
|
08/06/2016
00:00:00
|
10,000
|
DELHI
|
4
|
D
|
01/01/2016
00:00:00
|
07/06/2016
00:00:00
|
10,000
|
PUNE
|
5
|
E
|
01/01/2016
00:00:00
|
09/06/2016
00:00:00
|
10,000
|
NOIDA
|
6
|
F
|
01/01/2016
00:00:00
|
08/06/2016
00:00:00
|
10,000
|
BHUBANESWAR
|
7
|
G
|
01/01/2016
00:00:00
|
07/06/2016
00:00:00
|
10,000
|
HYDERABAD
|
8
|
H
|
01/01/2016
00:00:00
|
06/06/2016
00:00:00
|
10,000
|
KOLKATA
|
No comments:
Post a Comment