The 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.
SQL SELECT Syntax
SELECT column_name(s)
FROM table_name |
and
SELECT * FROM table_name
|
SQL SELECT Example
The "Persons" table:
Id
|
LastName
|
FirstName
|
Address
|
City
|
1
|
Navis
|
Anto
|
Madras
|
TVL
|
2
|
ji
|
Bala
|
Bombay
|
TVL
|
3
|
Christopher
|
Franklin
|
America
|
KK
|
Now we want to select the content of the columns named
"LastName" and "FirstName" from the table above.
The result-set will look like this:
SELECT * Example
Now we want to select all the columns from the "Persons"
table.
We use the following SELECT statement:
Tip: The asterisk (*) is a quick way of selecting all columns!
The result-set will look like this:
The result-set will look like this:
LastName
|
FirstName
|
Navis
|
Anto
|
ji
|
Bala
|
Christopher
|
Franklin
|
SELECT * Example
Now we want to select all the columns from the "Persons"
table.We use the following SELECT statement:
SELECT * FROM Persons
|
Tip: The asterisk (*) is a quick way of selecting all columns!
The result-set will look like this:
Id
|
LastName
|
FirstName
|
Address
|
City
|
1
|
Navis
|
Anto
|
Madras
|
TVL
|
2
|
ji
|
Bala
|
Bombay
|
TVL
|
3
|
Christopher
|
Franklin
|
America
|
KK
|
0 comments:
Post a Comment