88.6k views
4 votes
Which of these three last names will be matched by the WHERE clause in the following query? SELECT empID from personnel WHERE lastName LIKE 'T%o_er' 'Thrower' will be matched but 'Toer' and 'Toler' will not be matched All three last names will be matched 'Toer' will be matched but 'Toler' and 'Thrower' will not be matched 'Toler' and 'Thrower' will be matched but 'Toer' will not be matched

User Mitul Goti
by
5.6k points

1 Answer

2 votes

Answer:

'Toler' and 'Thrower' will be matched but 'Toer' will not be matched

Step-by-step explanation:

LIKE operator is used in where clause to find a pattern usually with wildcards '%' and '_'

  • '%' represents possible characters
  • '_' represents single character

for example select ... where .. name LIKE 'd%' matches all names starting with the character d and continue with any or no characters

select ... where .. name LIKE '_d%' matches all names starting with any character and has 'd' in the second position and continus with any possible characters.

Thus, SELECT empID from personnel WHERE lastName LIKE 'T%o_er' statement selects all employeeID's of the personnel whose last name Starts with T, continues with any possible characters and ends with the o, then any character, and 'er'.

Therefore 'Toler' and 'Thrower' will be matched but 'Toer' will not be matched because 'Toer' does not have a character between 'o' and 'er'.

User Izabel
by
5.6k points