Basic SQL Syntax
SELECT Statement:
Select
Statement used to retrieve the data from database (table)
and
the results are displays in table
format, called Result-set
Syntax for retrieving
all data from table:
SELECT * FROM table_name;
Syntax for retrieving
Selected Column data from table:
SELECT Columnname(s) FROM table_name;
Examples:
The
Table “Contact” has following data,
ID
|
NAME
|
DESIGNATION
|
CITY
|
MOBILE
|
1
|
venkat
|
CEO
|
Kodambakkam
|
999989845
|
2
|
Santhosh
|
manager
|
Puddukottai
|
9999898978
|
3
|
Kousilaya
|
Asst.manager
|
Trichy
|
9659315754
|
4
|
Ananth
|
CEO
|
Chennai
|
9999999945
|
5
|
Sajil
|
MD
|
Surandai
|
6677888997
|
We
use following statement,
SELECT
* FROM Contact;
The
Result-set is,
ID
|
NAME
|
DESIGNATION
|
CITY
|
MOBILE
|
1
|
venkat
|
CEO
|
Kodambakkam
|
999989845
|
2
|
Santhosh
|
manager
|
Puddukottai
|
9999898978
|
3
|
Kousilaya
|
Asst.manager
|
Trichy
|
9659315754
|
4
|
Ananth
|
CEO
|
Chennai
|
9999999945
|
5
|
Sajil
|
MD
|
Surandai
|
6677888997
|
We
use following statement,
SELECT
Name,Designation,Mobile FROM Contact;
The
Result-set is,
NAME
|
DESIGNATION
|
MOBILE
|
venkat
|
CEO
|
999989845
|
Santhosh
|
manager
|
9999898978
|
Kousilaya
|
Asst.manager
|
9659315754
|
Ananth
|
CEO
|
9999999945
|
Sajil
|
MD
|
6677888997
|
Note
that, SQL is not Case-Sensitive.
No comments:
Post a Comment