IPA IP 2024 Question 93
A question IPA Japan published in 令和6年度 ITパスポート試験 公開問題 問93, translated into English. ITPEC is based on the same exams.
From the “Employee” table managed in a relational database, the employees whose names match ‘%葉_’ were extracted. How many employees were extracted? Here, “_” represents any one (1) character, and “%” represents a character string that consists of zero (0) or more of any characters.
Employee
Explanation
2 employees — ‘%葉_’ matches a name whose second-to-last character is 葉: any characters or none before it, and exactly one character after it.
The pattern must match the whole name: % stands for zero or more characters and _ for exactly one, so 葉 has to be followed by exactly one character.
S001 and S003 are extracted.
Answer (b)
Why not others:
- •(a) 1 and (c) 3 — miscounts: exactly two names, S001 and S003, have one character after 葉
- •(d) 4 — reads
_as zero or one character, which adds S004 and S005, whose names end in 葉
Key rule: In an SQL LIKE pattern, % is any string including the empty one and _ is exactly one character, and the pattern covers the whole value, so '%X_' means X is the second-to-last character.
Databases · AI-written, may contain errors
This question comes from the past questions IPA Japan publishes, translated into English by ITPEC Practice. ITPEC Practice is an independent study tool and is not affiliated with IPA or ITPEC. See the original paper (PDF) or Report an issue.