Database Queries: Selection and Action Types

Classified in Computers

Written at on English with a size of 2.24 KB.

Database Queries

Queries are objects in a database that allow you to filter data in a table or query. They display data from a table that meet specified criteria.

Selection Queries

Selection Queries extract or show only the data that you specify. The results can be used to modify the data.

Action Queries

Action Queries make changes to records in a single operation. Types include delete, update, append, and create tables.

Creating a Selection Query

To create a select query, follow these steps:

  1. Open the database where you want to create the query.
  2. Click the Query object to the right of the database window.
  3. Click the New button in the database window.
  4. Select Design View.
  5. Click the OK button.
  6. Select the table to query.
  7. Click the Add button.
  8. For queries from multiple tables, repeat steps 6 and 7.
  9. After adding all necessary tables, click Close.
  10. At the top of the screen, tables are added with their fields. At the bottom, the QBE grid is used to specify query criteria. Each column corresponds to a field.
  11. Click the arrow in the first row and column of the grid. A drop-down list opens.
  12. Select the field. The second row shows the table name.
  13. Repeat steps 10 and 11 in the next column to select another field.
  14. Continue until all required fields are in the grid.
  15. Use the Sort row to specify sorting order (ascending or descending).
  16. Uncheck Show for fields not to be displayed in the query.
  17. Specify search criteria in the Criteria and O rows.

A search criterion is a condition that records must meet to appear in the query. Use AND and OR operators to combine conditions.

Example: price > 100 AND price < 1200 returns records where the price is between 101 and 1199.

Criteria in multiple fields are combined with AND. Criteria in separate rows are combined with OR.

Entradas relacionadas: