Information Technology • Databases

Query Grid

Table: Books

Click a field to add it to the grid.

    Query design

    Same row: AND · different rows: OR

    The SQL it makes

    
          

      Result

      Query Grid — Explanation

      A query finds the records in a table that meet some criteria, and shows the fields you choose. In Microsoft Access you build one in a grid, called query by example: one column per field, with rows for how to sort it, whether to show it and its criteria. This grid works the same way, and shows the SQL it turns into, live, and the result.

      In SQL, the shown fields follow SELECT, the criteria become WHERE (AND within a row, OR between rows), and the sorts ORDER BY. SQL uses % and _ as its wildcards where Access uses * and ?.

      Common exam mistakes: putting two criteria that must both be true on different rows (that's OR); putting "Mystery" and "Science" on the same row in one field (no record is both); forgetting the quotes, or the wildcard, in a Like criterion; using > where the question says "or more" (>=); leaving a criteria field showing when the question lists only some fields; sorting by the wrong field first.

      Objective: Cambridge IGCSE ICT (0417) section 18, databases: performing searches with single and multiple criteria, using AND, OR, NOT, LIKE, wildcards and comparison operators, sorting, and calculated fields in queries; Cambridge International AS Level IT (9626) database and file concepts: queries and SQL.

      Where this fits

      • Cambridge: Cambridge IGCSE Information and Communication Technology (0417); Cambridge A Level Information Technology (9626); Cambridge AS Level Information Technology (9626) Goes beyond Cambridge IGCSE Information and Communication Technology (0417): The live SQL view goes beyond 0417, which builds queries in the database's grid only.
      • NCEA Level 2 Digital Technologies: 91892 Use advanced techniques to develop a database
      • Pearson Edexcel International: Edexcel International GCSE ICT (4IT1); Edexcel International A Level Information Technology Goes beyond Edexcel International GCSE ICT (4IT1): Wildcards and calculated fields go beyond 4IT1's searches.

      Query Grid — Key Terms

      Key concepts in English, with te reo Māori, Chinese (Simplified) and Korean.

      EnglishTe reo Māori中文(简体)한국어What it means on this page
      Databasepātengi raraunga数据库데이터베이스A structured collection of related data: here, the school library's Books table.
      Table (relation)ripanga表테이블A grid of records and fields holding data about one kind of thing, such as books.
      Row (record)haupae / pūkete行행All the data about one item in a table: here, one book.
      Column (field)tīwae / āpure字段필드One item of data stored for every record, such as Title or Year.
      Primary keypātuhi matua主键기본 키The field that identifies each record: here, BookID.
      Queryno attested term查询질의 (쿼리)A search of a database for the records that meet some criteria, showing chosen fields.
      Query by Example (QBE)no attested term示例查询 (shìlì cháxún)—Building a query by filling in a grid of fields, sort orders and criteria, rather than writing SQL.
      Criteriano attested term条件 (tiáojiàn)조건 (jogeon)The conditions a record must meet to be found by a query, such as Genre = "Fantasy" or Year > 2020.
      Wildcardno attested term通配符 (tōngpèifú)와일드카드 (waildeukadeu)A character that stands for others in a search: * for any number of characters and ? for exactly one (% and _ in SQL).
      Calculated Fieldno attested term计算字段 (jìsuàn zìduàn)계산 필드 (gyesan pildeu)A new field in a query worked out from other fields, such as Sale: [Price]*0.9.
      Sortno attested term排序 (páixù)정렬 (jeongnyeol)To put records in order of a field's values: ascending (A to Z, smallest first) or descending.
      SQL (Structured Query Language)no attested term结构化查询语言 (SQL)구조적 질의 언어 (SQL)The standard language for defining, querying and changing the data in a relational database.

      On the te reo Māori column. Terms marked as gaps have no attested equivalent in the sources checked — Karaitiana Taiuru's Dictionary of Māori Computer and Social Media Terms, Paekupu, the Reserve Bank's te reo financial glossary, NZQA and Te Aka. No coinage is printed as though it were established; where a class needs one, commission it from Te Taura Whiri i te Reo Māori and credit the translator. Te reo Māori is not italicised and takes no plural "s".