Summary

This chapter presented syntax examples and results for basic kinds of SELECT statements that are used to query a relational database. The section Single-table SELECT statements shows how to perform the following actions:
  • Select columns and rows from a table with the Projection and FROM clauses
  • Select rows from a table with the Projection, FROM, and WHERE clauses
  • Use the DISTINCT or UNIQUE keyword in the Projection clause to eliminate duplicate rows from query results
  • Sort retrieved data with the ORDER BY clause and the DESC keyword
  • Select and order data values that contain non-English characters
  • Use the BETWEEN, IN, MATCHES, and LIKE keywords and various relational operators in the WHERE clause to create comparison conditions
  • Create comparison conditions that include values, exclude values, find a range of values (with keywords, relational operators, and subscripting), and find a subset of values
  • Use exact-text comparisons, variable-length wildcards, and restricted and unrestricted wildcards to perform variable text searches
  • Use the logical operators AND, OR, and NOT to connect search conditions or Boolean expressions in a WHERE clause
  • Use the ESCAPE keyword to protect special characters in a query
  • Search for NULL values with the IS NULL and IS NOT NULL keywords in the WHERE clause
  • Use the FIRST clause to specify that a query returns only a specified number of the rows that match the conditions of the SELECT statement
  • Use arithmetic operators in the Projection clause to perform computations on number fields and display derived data
  • Assign display labels to computed columns as a formatting tool for reports
This chapter also introduced simple join conditions that enable you to select and display data from two or more tables. The section Multiple-table SELECT statements describes how to perform the following actions:
  • Create a Cartesian product
  • Create a CROSS JOIN, which creates a Cartesian product
  • Include a WHERE clause with a valid join condition in your query to constrain a Cartesian product
  • Define and create a natural join and an equi-join
  • Join two or more tables on one or more columns
  • Use aliases as a shortcut in multiple-table queries
  • Retrieve selected data into a separate, temporary table with the INTO TEMP clause to perform computations outside the database