?
What will be the output of the following MySQL statement?
What will be the output of the following MySQL statement?
SELECT *
FROM employee
WHERE lname LIKE %bas% OR fname LIKE %bbs%;
SELECT *
FROM employee
WHERE lname LIKE %bas% OR fname LIKE %bbs%;
Answer & Solution
Correct Answer:
Option
C
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".
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".
Join the Discussion
Login to post a comment or share your explanation.
Login