SQL SELECT QUERY - The Coding Shala

Home >> Learn SQL >> SQL SELECT Query


SQL 'SELECT' statement is used to fetch data from the database table. Using 'SELECT' Statement we can fetch the whole table or some columns that we want.

SQL SELECT QUERY - The Coding Shala


The basic syntax of the SELECT statement is as follows - 
SELECT column1, column2, columnN FROM table_name; 

This Query will fetch only particular columns that are mentioned. If we want to fetch all the columns then use '*' instead of columns name.

SELECT * FROM table_name;  

SQL SELECT Query Examples - 

The following query will fetch all the data from the 'Persons' Table - 

SQL >> select * from Persons  

 Output >>   
 PersonID     LastName     FirstName     Address     City  
 1              Saini     Akshay         A-101     Pune  
 1              last     first            A-101     Pune  
 2              null     Akshay           null       null  

Now if we want to fetch only 'PersonID' and 'FirstName' then we use - 

SQL >> select PersonID, FirstName from Personsselect * from Persons  
Output >>   
 PersonID     FirstName  
 1          Akshay  
 1          first  
 2          Akshay  

Other Posts You May Like
Prev<< SQL INSERT Query                                                                               NEXT >>SQL Where Clause
Please leave a comment below if you like this post or found some error, it will help me to improve my content.


Popular Posts from this Blog

Anti Diagonals - The Coding Shala

Shell Script to find sum, product and average of given numbers - The Coding Shala

LeetCode - Bulb Switcher Solution - The Coding Shala

New Year Chaos Solution - The Coding Shala

Sorting the Sentence LeetCode Solution - The Coding Shala