ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

SELECT (Databases)

Definition - What does SELECT (Databases) mean?

A SELECT is the fundamental statement of structured query language (SQL).

The SELECT statement, which follows a consistent and specific format, begins with the SELECT keyword followed by the columns to be included in the format. If an asterisk (*) is placed after SELECT, this sequence is followed by the FROM clause that begins with the keyword FROM, followed by the data sources containing the columns specified after the SELECT clause. These data sources may be a single table, combination of tables, subquery or view.

Optional clauses may be added but are not mandatory, i.e., the WHERE clause that gives conditions for returning data, or the ORDER BY clause that sorts output with one or more of the specified columns.

Techopedia explains SELECT (Databases)

One of the first database administration lessons is the SELECT statement, which forms the beginning of any SQL script used to query data. SELECT is the first keyword in the SELECT statement, which, like all SQL statements, is not case-sensitive.

To illustrate the SELECT statement in an example, assume that a bank database contains a CUSTOMER_MASTER table that stores basic customer details and contains several columns named as follows:

  • customer_id
  • social_security_no
  • surname
  • firstname
  • email_address
  • physical_address
  • date_of_birth
  • gender


The following SELECT statement is used to query all table data:

SELECT * FROM customer_master.

The following SELECT statement is used to sort results by customer surnames:

SELECT * FROM customer_master ORDER BY surname

To list customer surnames, first names and dates of birth, the asterisk (*) is replaced with the corresponding column names, as follows:

SELECT surname, firstname, date_of_birth FROM customer_master

To run a query of all female customers sorted by date of birth, the following statement is issued:

SELECT * FROM customer_master WHERE gender=’F’ ORDER BY date_of_birth

Note: The WHERE clause is now used to restrict output.

This explanation is a simple primer that demonstrates the power of the SELECT statement and may be used to build complex and elaborate queries beyond this scope. However, all SELECT statements, regardless of scope, are required to consistently follow the basic rules outlined above.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.