Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Tuesday, April 16, 2013

5 : SQL "SELECT" STATEMENT


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


The created Table is : 


Create a Database named "Studysql" and a table named "tbl_biodata"
Right click on the database Studysql and select new query.Then we can write queries as per the requirements.
( Click here to know how created this table )

ID
NAME
AGE
CITY
PHONE
1
Priyada
25
Cochin
1000000001
2
Mohan
30
Cochin
2000000002
3
Jaimon Jacob
40
Vytila
3000000003
4
Sumith
24
Kottayam
4000000004
5
Shaiju
36
Thrissur
5000000005

We can select the table in 2 methods. First , we can select a part of the table , and second , we can select the whole table.

1. The SQL SELECT Statement(Selecting a part of the table).


Now , we want to SELECT the content of the column named "NAME" & " CITY" from the above table.
To do so, write the command like this in SQL.


SELECT names,city FROM tbl_biodata


Then ,Select EXECUTE (you can select the EXECUTE option from the menu " QUERY DESIGNER ").

The result-set will look like this:




SQL SELECT Syntax of the same is : 

SELECT column_name(s)
FROM table_name


2 . SELECT * Example

Now we want to select all the columns from the "tbl_biodata" table.

To do so, write the command like this in SQL.

select * from tbl_biodata







The result-set will look like this:



SQL SELECT Syntax of the same is : 

SELECT * FROM table_name



Tip: The asterisk (*) is a quick way of selecting all columns!
That is , this command is used to select all the fields from the table.




NEXT CHAPTER

No comments: