Skip to main contentSkip to solution

Which of the following query selects details of those employees whose name consists of exactly 4 letters and starts with letter 'p'?

Solution

✅ Correct Option: 1

In SQL, the LIKE operator uses _ to match exactly one character and % to match any number of characters (including none). The pattern 'p___' is the letter p followed by three single-character wildcards, so it matches names of exactly 4 letters that start with p.


Option 2: '___p' matches 4-letter names that end with p, not start with it.

Option 3: 'p%' matches any name starting with p, of any length.

Option 4: '%p__' matches names with p as the third-last letter, of any length of 3 or more.

Remember: _ fixes the number of characters, while % leaves the length open.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question