Skip to content

令和6年度 ITパスポート試験 問93

This question's explanation and your answers so far.

問93
頻出度★★☆

関係データベースで管理している“従業員”表から,氏名が‘%葉_’に該当する従業員を抽出した。抽出された従業員は何名か。ここで,“_”は任意の1文字を表し,“%”は0文字以上の任意の文字列を表すものとする。 従業員

従業員番号氏名
S001千葉翔
S002葉山花子
S003鈴木葉子
S004佐藤乙葉
S005秋葉彩葉
S006稲葉小春
出典 令和6年度 ITパスポート試験 問93
解説

問 93

  • Incorrectア

    1 is an undercount. Not only 千葉翔 but also 鈴木葉子 meets the condition, for a total of 2. This is the mistake of picking up only one name in which 葉 is the second-to-last character.

  • イ

    正解 By the definition of wildcards, the pattern “%葉_” can be read as “% (any string of zero or more characters) + 葉 + _ (any single character).” In other words, the selection condition is “a name whose second-to-last character is 葉, with exactly one more character following it.” Applying this to each row, only 千葉翔 (千/葉/翔: 葉 is followed by the single character 翔) and 鈴木葉子 (鈴木/葉/子: 葉 is followed by the single character 子) — 2 records — match this form. Therefore the number of selected employees is 2, and the correct answer is イ.

  • Incorrectウ

    3 is an overcount. In 佐藤乙葉, 葉 is the last character and there is no single character (_) after it, so it does not match. Wrongly including names ending in 葉 leads to too many.

  • Incorrectエ

    4 is an overcount. In 葉山花子, 秋葉彩葉, and 稲葉小春, 葉 is followed by two or more characters, so they do not satisfy the condition of _ (exactly one character). This is the mistake of counting names that merely contain 葉.

ここがポイント
  • The wildcard “_” represents exactly one arbitrary character, while “%” represents an arbitrary string of zero or more characters. The key point is to accurately distinguish their difference in length (fixed at one character versus variable).
  • Be aware of how the pattern matches at the end of the string. Since “%葉_” has the form “exactly one character remains right after 葉,” names ending in 葉 and names with two or more characters after 葉 are both excluded.
用語

Your answers