Select Statement or Select Query in SQL Explained with Examples
Select Statement
The SELECT statement is used for the selection of data from a database. This statement is widely used both by the database administrators as well as developers.
Syntax
SELECT col_name_1, col_name_2, …, col_name_n
FROM tbl_name;
In the above syntax, SELECT keyword is a command understood by DBMS to fetch data. Col_name_1 and col_name_2 upto col_name_n are the columns to be retrieved. Next, the keyword FROM is a command to specify the source Table and finally, tbl_name is the target table, from where the records are to be fetched.
Another syntax that is quite common in use, is:
SELECT *
FROM tbl_name;
Here too, the SELECT keyword is a command to fetch data, FROM keyword is a command to specify the source table and tbl_name is the target table. The new element is * which is a wildcard and that refers to the selection of all the columns residing within the target table.
Example
SELECT ID, C_Name, Status FROM Customers
ID | C_Name | Status |
1 | Tim Robbins | Active |
2 | James Chris | Active |
3 | Kevin Sputnik | Inactive |
4 | Richard Butler | Active |
5 | David McGregor | Active |
Also
SELECT * FROM Customers
ID | C_Name | Contact_No | City | Status | |
1 | Tim Robbins | +44 54 443-4434 | London | [email protected] | Active |
2 | James Chris | +44 54 498-3476 | Birmingham | [email protected] | Active |
3 | Kevin Sputnik | +44 54 487-6987 | Manchester | [email protected] | Inactive |
4 | Richard Butler | +44 54 422-2345 | Birmingham | [email protected] | Active |
5 | David McGregor | +44 54 413-0989 | Cardiff | [email protected] | Active |
Navigation in a Result-set
Most of the database management systems allow navigation within the result-set through programming functions, for instance Go to First Record, Go to Last Record, Move Next, Move Previous, etc.
More Related Articles For You
- Architecture of DBMS
- CODDS RULE DBMS
- Database Models in DBMS
- Relational DBMS Concepts
- Keys and Types of keys in Database
- Database Normalization
- Generalization, Specialization and Aggregation Concepts in DBMS
- ERD Diagram Tutorial with Examples in DBMS
- Introduction to SQL
- How to Create Query in SQL, Create Table, Delete Table and User Insert Info Statements
- Alter Query Command in SQL, Add, Modify and Drop Column in Table
- TCL Commands in SQL
- Truncate Query, Drop and Rename Query in SQL
- All DML Statement in SQL, Select Statement, Delete, Insert and Update Statement
- Data Control Language DCL Revoke and Grant Command in SQL
- Distinct Keyword Explained in SQL
- WHERE Statement or WHERE Clause in SQL Statement Explained
- AND & OR Operators in SQL
- LIKE Operator in SQL
- ORDER BY Clause Sorting Explained in SQL
- Group By Clause in SQL
- Having Clause Explained in SQL
- SQL Constraints
- SQL Aggregate Functions
- SQL Aliases Use and Purpose in SQL
- SQL Joins Types, Use and Purpose
- SQL Sequence Syntax and Use with Examples
- SQL View
- SET Operation in SQL, UNION, UNION ALL, Intersect and Minus