SQL SELECT is a keyword and statement for selecting, re­triev­ing and dis­play­ing data in columns and tables. It serves as the found­a­tion for the majority of queries and actions in SQL, making it one of the most important tools in the language.

What is SQL SELECT?

The bigger the database, the more difficult it is to retrieve relevant in­form­a­tion and records. That’s why SELECT is of the most important tools in SQL for efficient queries and state­ments. SQL SELECT specifies which records and columns you want to find, display and edit.

When combined with other SQL commands, SQL operators and SQL functions, SELECT can perform com­par­is­ons, cal­cu­la­tions and pattern-based searches. For example, SQL SELECT DISTINCT delivers results without du­plic­ates. SQL SELECT INTO copies data from an existing table into a new one. And SQL SELECT TOP limits the number of results.

Tip

Learn the basics of SQL and get started with this popular database language. Our SQL in­tro­duc­tion with examples provides an overview!

What is the syntax of SQL SELECT?

The basic syntax of SQL SELECT looks as follows:

SELECT  *
FROM  Table
sql

It uses the following para­met­ers:

  • SELECT: Selects the records and columns that are relevant for your query or action. You can name specific columns using primary or foreign keys or use an asterisk * to copy all the data in the source table.
  • FROM: Specifies the table that the records and columns are located in.

Ad­di­tion­al optional elements include:

  • WHERE: An optional SQL WHERE clause can be used to set criteria that the data from the source table should fulfill.
  • GROUP BY: Groups target data in groups or cat­egor­ies.
  • ORDER BY: Sorts the data that you retrieve using SELECT in an order of your choosing. Can be further specified with ASC for ascending order or DESC for des­cend­ing.
  • SELECT TOP: Limits the number of results that are displayed.
  • SELECT DISTINCT: Removes du­plic­ates from the records in the result table.

What is SQL SELECT used for?

SQL SELECT forms the found­a­tion of most queries, making it in­dis­pens­able for database man­age­ment systems. It’s used across in­dus­tries in fields like marketing and sales, human resources, finance, logistics and pro­duc­tion.

Here are some practical use cases from different in­dus­tries:

  • Limiting data analyses of tables with customer data to specific columns like ‘ID’, ‘Address’ or ‘Name’
  • Selecting products or services based on geo­graph­ic or demo­graph­ic factors
  • Measuring the success of marketing campaigns using keywords like traffic, in­ter­ac­tions and con­ver­sions
  • In­di­vidu­al­ising email campaigns, gen­er­at­ing leads or creating offers
  • Analysing sus­pi­cious trans­ac­tions using selected records related to average values or threshold values
  • Managing employee data or ap­plic­a­tion data
  • Mon­it­or­ing inventory or quality control
Tip

You’re looking for a flexible, scalable, in­di­vidu­al­ised server and hosting solution? Then SQL Server Hosting from IONOS might be right for you – with fast access times, high per­form­ance and fail safe security.

VPS Hosting
VPS hosting at un­beat­able prices on Dell En­ter­prise Servers
  • 1 Gbit/s bandwidth & unlimited traffic
  • Minimum 99.99% uptime & ISO-certified data centres
  • 24/7 premium support with a personal con­sult­ant

Examples of SQL SELECT in use

We’ll now take a closer look at how SQL SELECT works, using 2 examples.

Re­triev­ing customer in­form­a­tion

In this example you want to retrieve in­form­a­tion from the ‘Name’, ‘Address’ and ‘Cus­tom­erID’ columns in a table called ‘Customers’:

SELECT  Name, Address, CustomerID
FROM  Customers
sql

Re­triev­ing and sorting orders from a certain product category

In this next example, you want to retrieve all the orders for elec­tron­ics products, in the ‘Product_category’ column in a table called ‘Orders’ and sort them in des­cend­ing order based on price.

SELECT  Products, Product_category, Price
FROM  Orders
WHERE  Product_category =  'Electronics'
ORDER BY  Price  DESC
sql

Are there al­tern­at­ives to SQL SELECT?

SQL SELECT is a central element in SQL queries and database man­age­ment. For this reason, there is no al­tern­at­ive function for re­triev­ing in­form­a­tion from databases.

Go to Main Menu