SQL SELECT QUERY - The Coding Shala

Home >> Learn SQL >> SQL SELECT Query

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

SQL SELECT Syntax


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.

Comments

Popular Posts from this Blog

Java Program to Convert Binary to Decimal - The Coding Shala

N-th Tribonacci Number Solution - The Coding Shala

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

Shell Script to Create a Simple Calculator - The Coding Shala

Java Program to Convert Decimal to Binary - The Coding Shala