SQL SELECT Statement


The SQL SELECT statement is the most frequently used SQL query or command. It is used to fetch or retrieve all data (columns and rows) or partial (specific columns) data from a database table.

The SQL SELECT command returns matched query data in the form of table (rows and columns).
These tables are called result set or result table.

You can also search these topics using sql select into statement, mssql select into, sql select into temp table, select into temp table, postgresql select into, sql server select into existing table, select into example, select into new table, sql server select into temp table, sql select into new table, create table select into, select into temp table sql server, insert select into table, sql select into from, select into existing table.

Sql Select Query Syntax

The below syntax is used to select specific column(s) from the specific table.


SELECT 
column_name1, column_name2, column_nameN 
FROM table_name;

The below syntax is used to select all column(s) from the specific table.


SELECT * FROM table_name;

Note:- You can write all SQL statements in a single line or multiple line.

  • SELECT - The SELECT command specifies the list of columns that are retrieved from the table.
  • FROM - The FROM command specifies from where data should be retrieved.

Sample Database Table - Books

BookID BookName BookPrice
1 Easy Oracle PL/SQL Programming 195
2 Professional MySql 150
3 Foundations Of Sql Server 2008 145
4 Making Sense Of SQL 165

SELECT Specific Column Example

The following SQL SELECT statement selects the "BookName" and "BookPrice" columns from the "Books" table:


SELECT 
BookName, BookPrice 
FROM Books;

Note: Column names are separated by commas(,).

The result of above query is:

BookName BookPrice
Easy Oracle PL/SQL Programming 195
Professional MySql 150
Foundations Of Sql Server 2008 145
Making Sense Of SQL 165

SELECT * Example

The following SQL SELECT statement selects all the column names or fields of "Books" table:


SELECT * FROM Books;

Note: '*' is a special characters, which is used to select all columns from the table.

The result of above query is:

BookID BookName BookPrice
1 Easy Oracle PL/SQL Programming 195
2 Professional MySql 150
3 Foundations Of Sql Server 2008 145
4 Making Sense Of SQL 165
You can also search these topics using copy sql database, sql copy data from one table to another, copy data from one table to another in sql, copy data from one table to another sql, copy from table to table sql, sql copy from table to table, sql copy data between tables, create copy of table sql, create table as select, create table from select, sql create table from select, insert create table, create table with insert, create table select sql.