SQL SELECT Statement

SQL SELECT statement is the most commonly used statement. It is used to retrieve the selected data from a table following the conditions we use.

 

The syntax of select statement is

SELECT *
FROMtable_name
WHERE conditions;

 

Here ‘*’ is an expression and is used when all columns are to be retrieved.

If any particular column is to be retrieved then the column name must be in the place of ‘*’.

The conditions are optional when using the SELECT statement.

 

Example:

Let us take a Student table in a database.

StudentIDStudent_NameAddressCity
1NithinBank StreetHyderabad
2BharathWhite FieldBangalore
3GouthamAvenue colonyChennai

 

 

 


If you want to select the data from the above table then it is written as follows:

SELECT * FROM Student;

 

The output of the above statement is given as

1NithinBank StreetHyderabad
2BharathWhite FieldBangalore
3GouthamAvenue colonyChennai

 

 

 

If you want to select any particular column like Student_Name here then the query is written as

SELECTStudent_NameFROM Student;

 

Then the data will be displayed as

Nithin
Bharath
Goutham

 

If you want to retrieve more than one column then the column names should be separated by a comma (,)