Queries
Overview
An SQL query is any statement that returns rows or records. Typically, a query will start with the SELECT or SELECT DISTINCT keywords. For example, the following is a simple SQL query.
SELECT * FROM Employee WHERE years_of_service > 5;In this example:
- 
SELECTis a statement keyword.
- 
*is an identifier or selector that means "select all columns".
- 
FROMis a clause that tells the engine from where (which table) we are selecting all of the columns.
- 
Employeeis an identifier that specifies the "Employee" table in the database.
- 
WHEREis an optional clause that specifies under what conditions the engine is to return a record or row.
- 
years_of_serviceis an identifier that specifies a specific column called "years_of_service" in the "employees" table.
- 
>is an operator that compares two values, and returns TRUE or FALSE.
- 
5is an integer.
- 
Collectively, years_of_service > 5is a predicate.
Ultimately, this query will return all columns from all rows from the "employees" table where the "years_of_service" column has a value greater than 5.