Preamble
With the SQL SELECT operator, you can get records from one or more tables in an SQL database.
Syntax of the SELECT operator
SELECTexpressions_id
FROM tabs
[WHERE conds]
Parameters or arguments
- expressions_id – fields or calculations that you want to get.
- tabs – tables from which you want to upload data. After FROM operator at least one table must be specified.
- WHERE conds – Optional. Conditions that must be met for the records to be selected. If no conditions are specified, all records will be selected.
SELECTING ALL FIELDS FROM ONE TABLE
Consider an example showing how to use the SQL SELECT operator, which selects all fields from a table.
SELECT *
FROM suppls
WHERE city_id = 'London'.
ORDER BY city_id DESC;
In this example of a SQL SELECT statement, we used * to view all fields from the suppliers table where the suppliers live in London. The resulting set is sorted by city in descending order.
SELECT INDIVIDUAL FIELDS FROM THE SAME TABLE
You can also use the SQL SELECT statement to select individual fields from a table.
SELECT suppl_name,
city_id,
state_id
FROM suppls
WHERE suppl_id > 1000
ORDER BY suppl_name ASC, city_id DESC;
This SQL SELECT example will only return suppl_name, city_id, state_id fields from a suppls table where the suppl_id value exceeds 1000. The results are sorted by suppl_name in ascending order, and city in descending order.
SELECTION OF FIELDS FROM SEVERAL TABLES
You can also use the SQL SELECT statement to extract fields from multiple tables.
SELECT ords.order_id,
suppls.suppl_name
FROM suppls
INNER JOIN ords
ON suppls.suppl_id = ords.suppl_id
ORDER BY ord_id;
This SQL SELECT example connects two tables into the resulting set, showing the order_id and suppl_name fields where the suppl_id value is in both the suppls and order tables. The results are sorted by order_id in ascending order.
Read more about SQL joins
Practical Exercise #1
Based on the employee table below, select all fields whose salary is less than or equal to $ 52,500 (sorting is not required):
--create table empls
CREATE TABLE empls
( empl_number int NOT NULL,
empl_name char(50) NOT NULL,
salary_id int,
CONSTRAINT empls_pk PRIMARY KEY (empl_number)
);
-- insert entries in the empls table.
insert into empls values (1, 'Kuzjakin', 3500);
insert into empls values (2, 'Bakini',7200);
insert into empls values (3, 'Galingen',51000);
insert into empls values (4, 'Medajan',68000);
insert into empls values (5, 'Simkhan',85200);
Contents of the empls table:
| empl_number | empl_name | salary_id |
| 1 | Kuzjakin | 3500 |
| 2 | Bakini | 7200 |
| 3 | Galingen | 51000 |
| 4 | Medajan | 68000 |
| 5 | Simkhan | 85200 |
Solution for Practical Exercise #1:
The next SQL SELECT statement will select records from the empls table:
SELECT *
FROM empls
WHERE salary_id <= 52500;
As a result of sampling we’ll get:
| empl_number | empl_name | salary_id |
| 1 | Kuzjakin | 3500 |
| 2 | Bakini | 7200 |
| 3 | Galingen | 51000 |
Practical Exercise #2
Based on the table below, select the unique city_id values that are in Florida and organize the results in descending order by city_id:
--create a suppls table
CREATE TABLE suppls
( suppl_id int NOT NULL,
suppl_name char(50) NOT NULL,
city_id char(50),
state_id char(25),
CONSTRAINT suppls_pk PRIMARY KEY (suppl_id)
);
-- insert entries in the suppls table.
insert into suppls values (1, 'Mari', 'Houston', 'Texas');
insert into suppls values (2, 'Frida', 'Melbourne', 'Florida');
insert into suppls values (3, 'Madlen', 'Phoenix', 'Arizona');
insert into suppls values (4, 'Valentina', 'San Diego', 'California');
insert into suppls values (5, "Amba", "Jacksonville", "Florida");
Contents of the suppls table:
| suppl_id | suppl_name | city_id | state_id |
| 1 | Mari | Houston | Texas |
| 2 | Frida | Philadelphia | Pennsylvania |
| 3 | Madlen | Phoenix | Arizona |
| 4 | Valentina | SanDiego | California |
| 5 | Amba | Jacksonville | Florida |
Solution for Practical Exercise #2:
The following SQL SELECT operator selects records from the suppls table:
SELECT DISTINCT city_id
FROM suppls
WHERE state_id = 'Florida'.
ORDER BY city_id DESC;
The result of the sample will be:
| city_id |
| Jacksonville |
| Melbourne |
Practical Exercise #3
Based on the suppliers and orders tables below, select the suppl_id and suppl_name fields from the suppls table, and select the order_date field from the ords table, where the suppl_id field value in the suppliers table matches the suppl_id field value in the orders table. Sort the results by suppl_id in descending order.
--create the suppls table
CREATE TABLE suppls
( suppl_id int NOT NULL,
suppl_name char(50) NOT NULL,
city_id char(50),
state_id char(25),
CONSTRAINT suppls_pk PRIMARY KEY (suppl_id)
);
-- insert entries in the suppls table.
insert into suppls values (1, 'Mari', 'Houston', 'Texas');
insert into suppls values (2, 'Frida', 'Melbourne', 'Florida');
insert into suppls values (3, 'Madlen', 'Phoenix', 'Arizona');
insert into suppls values (4, 'Valentina', 'San Diego', 'California');
insert into suppls values (5, "Amba", "Jacksonville", "Florida");
Contents of the suppls table:
| suppl_id | suppl_name | city_id | state_id |
| 1 | Mari | Houston | Texas |
| 2 | Frida | Philadelphia | Pennsylvania |
| 3 | Madlen | Phoenix | Arizona |
| 4 | Valentina | SanDiego | California |
| 5 | Amba | Jacksonville | Florida |
–create an ords table
CREATE TABLE ords
( order_id int NOT NULL,
suppl_id int NOT NULL,
order_date date NOT NULL,
quantity int,
CONSTRAINT ords_pk PRIMARY KEY (order_id)
);
-- insert entries in the table of orders
insert into ords values (1.1, '05.05.2014', 100);
insert into ords values (2,3,'12.02.2015',300);
insert into ords values (3,5,'12.01.2016',500);
Contents of the table:
| suppl_id | suppl_name | ord_date |
| 5 | Amba | 12.01.2016 |
| 3 | Madlen | 12.02.2015 |
| 1 | Mari | 05.05.2014 |
SELECT statement in SQL Server
About Enteros
Enteros offers a patented database performance management SaaS platform. It finds the root causes of complex database scalability and performance problems that affect business across a growing number of cloud, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
How Enteros Transforms Healthcare Cost Management with AI Financial Intelligence and Database Performance Optimization
- 4 December 2025
- Database Performance Management
Introduction The healthcare sector is facing unprecedented financial and operational pressure. As medical organizations modernize their IT environments—embracing AI-driven diagnostics, telemedicine platforms, electronic health record (EHR) systems, imaging repositories, and cloud-native applications—the cost of operating these digital workloads continues to surge. At the same time, inefficiencies within databases, data pipelines, clinical software platforms, and analytics … Continue reading “How Enteros Transforms Healthcare Cost Management with AI Financial Intelligence and Database Performance Optimization”
Optimizing Retail Digital Operations: Enteros AI Platform for Accurate Cost Estimation and Superior Performance Management
Introduction The retail sector is undergoing one of the fastest digital transformations in history. From omnichannel commerce and predictive analytics to inventory automation and personalized customer experiences, today’s retail enterprises depend on complex, high-volume digital systems. These systems—spanning eCommerce platforms, databases, cloud services, POS solutions, and logistics software—process massive real-time workloads that directly influence customer … Continue reading “Optimizing Retail Digital Operations: Enteros AI Platform for Accurate Cost Estimation and Superior Performance Management”
How Technology Teams Improve Performance Management with Enteros’ AIOps and AI-First Operations Framework
- 3 December 2025
- Database Performance Management
Introduction The technology sector is undergoing a rapid transformation as cloud-native architectures, SaaS ecosystems, and real-time data systems redefine how organizations operate. Yet with this digital acceleration comes an overwhelming surge in complexity — distributed microservices, multi-cloud deployments, AI-augmented workflows, and massive data pipelines that demand precision, speed, and resilience. To navigate this complexity, enterprises … Continue reading “How Technology Teams Improve Performance Management with Enteros’ AIOps and AI-First Operations Framework”
The Future of Healthcare Databases: Enteros’ GenAI and AI Performance Management at Work
Introduction The healthcare sector is undergoing a digital revolution unlike anything seen before. From AI-assisted diagnostics and precision medicine to telehealth platforms and clinical research systems, today’s healthcare organizations rely heavily on massive data ecosystems. Databases power everything — electronic health records (EHRs), patient management systems, revenue cycle applications, insurance claim platforms, imaging archives, and … Continue reading “The Future of Healthcare Databases: Enteros’ GenAI and AI Performance Management at Work”