Examveda

What will be the output of the following MySQL statement?
SELECT *
FROM employee
WHERE lname LIKE %bas% OR fname LIKE %bbs%;

A. All employees whose last name should contain substring "bas"

B. All employees whose first name should contain substring "bbs"

C. All employees whose last name should contain substring "bas" or first name should contain substring "bbs"

D. None of the mentioned

Answer: Option C

Solution (By Examveda Team)

This question is about how to use the LIKE operator with wildcards in MySQL to find specific data.
Let's break down the code:
* SELECT *: This selects all the data from the 'employee' table.
* FROM employee: This tells the database to look for information in the 'employee' table.
* WHERE lname LIKE %bas% OR fname LIKE %bbs%: This is the important part! Here's what it means:
* lname LIKE %bas%: This finds any employee where the last name (lname) contains the substring "bas". The '%' symbol acts as a wildcard, meaning it can match any number of characters.
* fname LIKE %bbs%: This finds any employee where the first name (fname) contains the substring "bbs".
* OR: This combines the two conditions. The query will return employees that match either the last name condition or the first name condition.
So, the correct answer is Option C: All employees whose last name should contain substring "bas" or first name should contain substring "bbs".
This query will retrieve all employee records where either the last name contains "bas" or the first name contains "bbs".

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous