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:

  • SELECT is a statement keyword.

  • * is an identifier or selector that means "select all columns".

  • FROM is a clause that tells the engine from where (which table) we are selecting all of the columns.

  • Employee is an identifier that specifies the "Employee" table in the database.

  • WHERE is an optional clause that specifies under what conditions the engine is to return a record or row.

  • years_of_service is 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.

  • 5 is an integer.

  • Collectively, years_of_service > 5 is 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.