The majority of database operations are executed using SQL statements, which are comprised of easily comprehensible keywords.
Below is an SQL statement that retrieves all records from a table named “Customers”:
Retrieve all entries from the Customers table.
SELECT * FROM Customers; |
This tutorial will comprehensively cover various SQL statements.
A typical database comprises one or more tables, each identified by a name (e.g., “Customers” or “Orders”), and holds records (rows) containing data.
In this tutorial, we will utilize the widely recognized Northwind sample database (available in MS Access and MS SQL Server).
Displayed below is a portion of the Customers table referenced in the examples:
CustomerID |
CustomerName |
ContactName |
Address |
City |
PostalCode |
Country |
1 |
Alfreds Futterkiste |
Maria Anders |
Obere Str. 57 |
Berlin |
12209 |
Germany |
2 |
Ana Trujillo Emparedados y helados |
Ana Trujillo |
Avda. de la Constitución 2222 |
México D.F. |
05021 |
Mexico |
3 |
Antonio Moreno Taquería |
Antonio Moreno |
Mataderos 2312 |
México D.F. |
05023 |
Mexico |
4 |
Around the Horn |
Thomas Hardy |
120 Hanover Sq. |
London |
WA1 1DP |
UK |
5 |
Berglunds snabbköp |
Christina Berglund |
Berguvsvägen 8 |
Luleå |
S-958 22 |
Sweden |
The displayed table comprises five records, each representing a distinct customer, and includes seven columns: CustomerID, CustomerName, ContactName, Address, City, PostalCode, and Country.
Throughout this tutorial, we will render all SQL keywords in uppercase.
Certain database systems mandate a semicolon at the conclusion of each SQL statement.
The semicolon serves as the conventional means of delimiting individual SQL statements in systems permitting the execution of multiple SQL statements within the same server call.
Throughout this tutorial, we will adhere to using a semicolon at the conclusion of each SQL statement.