Examveda

What will be the output of the following MySQL statement?
SELECT *
FROM employee
WHERE lname LIKE ‘F%’ OR lname LIKE ‘%T’;

A. All employees whose last name should started with 'F'

B. All employees whose last name end with 'T'

C. All employees whose last name should started with 'F' and end with 'T'

D. None of the mentioned

Answer: Option C

Solution (By Examveda Team)

This question is asking about how to use the LIKE operator in MySQL to find employees with specific patterns in their last names. Let's break it down:
The LIKE operator is used for pattern matching. The percent sign (%) is a wildcard that represents zero or more characters.
Here's how the statement works:
* `lname LIKE ‘F%’`: This part finds employees whose last names start with the letter 'F' followed by any number of other characters.
* `lname LIKE ‘%T’`: This part finds employees whose last names end with the letter 'T', and can have any characters before it.
* `OR`: The OR keyword means that the query will return employees who meet either condition.
Therefore, the correct answer is Option D: None of the mentioned. The query will return all employees whose last name starts with 'F' OR ends with 'T'. It won't necessarily include employees whose last names both start with 'F' and end with 'T'.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous