関係データベースで管理している“従業員”表から,氏名が‘%葉_’に該当する従業員を抽出した。抽出された従業員は何名か。ここで,“_”は任意の1文字を表し,“%”は0文字以上の任意の文字列を表すものとする。 従業員
| 従業員番号 | 氏名 |
|---|---|
| S001 | 千葉翔 |
| S002 | 葉山花子 |
| S003 | 鈴木葉子 |
| S004 | 佐藤乙葉 |
| S005 | 秋葉彩葉 |
| S006 | 稲葉小春 |
This question's explanation and your answers so far.
関係データベースで管理している“従業員”表から,氏名が‘%葉_’に該当する従業員を抽出した。抽出された従業員は何名か。ここで,“_”は任意の1文字を表し,“%”は0文字以上の任意の文字列を表すものとする。 従業員
| 従業員番号 | 氏名 |
|---|---|
| S001 | 千葉翔 |
| S002 | 葉山花子 |
| S003 | 鈴木葉子 |
| S004 | 佐藤乙葉 |
| S005 | 秋葉彩葉 |
| S006 | 稲葉小春 |
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 イ.
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.
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 葉.