SQL Basic- SQL SELECT Command


SQL SELECT Command:


This SQL statement is used to show data from database.
The result is stored in result table, called
RESULT SET.


RESULT SET

A Result Set is returned to the Execute SQL task depends on the type of SQL command that the task uses. For example, a SELECT statement typically returns a result set, but an INSERT statement does not.



Syntax:


SELECT column_name 
FROM table_name;                                 //This statement returns as per defined 'column_name' in statement.


or


SELECT *
FROM table_name  
                                  //This statement returns all  details  from table.



Example:



Table:    'Student'


StudentID            StudentName              Address               Country
1            Ajay              Noida               India
2            Ajeet              Bareilly               India
3            Shivam              Nagaland               India

SELECT Column wise:


SELECT StudentID, StudentName, AddressFROM Student


After executing this statement, it result is



StudentID            StudentName              Address
1            Ajay              Noida
2            Ajeet              Bareilly
3            Shivam              Nagaland

SELECT * wise:


SELECT * FROM Student


After executing this statement, it result is


StudentID            StudentName              Address               Country
1            Ajay              Noida               India
2            Ajeet              Bareilly               India
3            Shivam              Nagaland               India