Introduction SQL

Basic SQL

SQL Constraints

Advance SQL

SQL Joins

SQL Function



SQL SELECT Statement


SQL SELECT Statement is used to viewing data from the table. This statement return list of table format table data.

We use asterisk (*) sign to fetch all table columns instead of write all column name.

SQL SELECT Statement is used this four type:


SELECT All Rows and All Columns

Syntax :

SELECT * FROM table_name;

Example Statement :

SQL> SELECT * FROM users_info;

 NO NAME              ADDRESS                        CONTACT_NO
--- ----------------- ------------------------------ -------------------
  1 Opal Kole         63 street Ct.                  000-444-8291
  2 Max Miller        41 NEW ROAD.                   000-444-8736
  3 Beccaa Moss       2500 green city.               000-444-8030
  4 Paul Singh        1343 Prospect St               000-444-8029
  5 Ken Myer          137 Clay Road                  000-444-7972
  6 Jack Evans        1365 Grove Way                 000-444-8845
  7 Reed Koch         1274 West Street               000-444-5672
  8 Gabe Hee          1220 Dallas Drive              000-444-5472
  9 Ben Mares         101 Candy Road                 000-444-6372
 10 Sariya Vargas     10 Texo Court.                 000-444-6371     

10 rows selected.

SELECT All Rows and Selected Columns

Syntax :

SELECT column_name1, column_name2, ... FROM table_name;

Example Statement :

SQL> SELECT no, name, address FROM users_info;

 NO NAME                  ADDRESS                        
--- --------------------- --------------------------------
  1 Opal Kole             63 street Ct.                  
  2 Max Miller            41 NEW ROAD.                  
  3 Beccaa Moss           2500 green city.               
  4 Paul Singh            1343 Prospect St               
  5 Ken Myer              137 Clay Road                 
  6 Jack Evans            1365 Grove Way                 
  7 Reed Koch             1274 West Street               
  8 Gabe Hee              1220 Dallas Drive              
  9 Ben Mares             101 Candy Road                 
 10 Sariya Vargas		  10 Texo Court. 

10 rows selected.

Only Selected Rows and All Columns

Syntax :

SELECT * FROM table_name [ WHERE condition ];

Example Statement :

SQL> SELECT * FROM users_info WHERE no = 3;

 NO NAME              ADDRESS                        CONTACT_NO
--- ----------------- ------------------------------ -------------------
  3 Beccaa Moss       2500 green city.               000-444-7586

Selected Rows and Selected Columns

Syntax :

SELECT column_name1, column_name2, ... FROM table_name [ WHERE condition ];

Example Statement :

SQL> SELECT no, name, address FROM users_info WHERE no = 3;

 NO NAME                  ADDRESS                        
--- --------------------- -------------------------------
  3 Beccaa Moss           2500 green city.               

SQL SELECT Syntax

Following is SELECT syntax include full details information.

SELECT [ DISTINCT | ALL ] 
	column_name1, column_name2, aggregate_function(column_name) ....
	[ FROM table_name ]
    [ WHERE condition ]
    [ GROUP BY groupby_column_name1, .... ]
    [ HAVING having_clause ]
    [ ORDER BY order_column_name1 [ ASC | DESC ], .... ];