The SQL SELECT
statement is used to select (retrieve) data from a database table. For example,
SELECT first_name, last_name
FROM Customers;
Here, the SQL command selects the first_name and last_name of all Customers.

SQL SELECT ALL
To select all columns from a database table, we use the *
character. For example,
SELECT *
FROM Customers;
Here, the SQL command selects all columns of the Customers table.

SQL SELECT WHERE Clause
A SELECT
statement can have an optional WHERE
clause. The WHERE
clause allows us to fetch records from a database table that matches specified condition(s). For example,
SELECT *
FROM Customers
WHERE last_name = 'Doe';
Here, the SQL command selects all customers from the Customers table with last_name Doe.

Let's see another example.
SELECT age, country
FROM Customers
WHERE country = 'USA';
Here, the SQL command fetches age
and country
fields of all customers whose country
is USA.

Note: In SQL, we must enclose textual data inside either single or double quotations like 'USA'
in our example.
SQL Operators
The WHERE
clause uses operators to construct conditions. Some of the commonly used operators are:
1. Equal to Operator (=)
SELECT *
FROM Customers
WHERE first_name = 'John';
This SQL command selects all customers from the Customers table having first_name John.
2. Greater than (>)
SELECT *
FROM Customers
WHERE age > 25;
This SQL command selects all customers from the Customers table having age greater than 25.
3. AND Operator (AND)
SELECT *
FROM Customers
WHERE last_name = 'Doe' AND country = 'USA';
This SQL command selects all customers from the Customers table having last_name Doe and country
USA.
Note: If the WHERE
clause condition does not meet with any rows, an empty result set is returned.
To learn more about all the SQL operators in detail, visit SQL Operators.