Examveda

What will be the output of the following MySQL statement?
SELECT emp_id, fname, lname
FROM employee
WHERE LEFT (lname, 1) =’F’;

A. Only those employees are selected whose last name started with 'F'

B. Only those employees are selected whose last name started with other than 'F'

C. All of the mentioned

D. None of the mentioned

Answer: Option A

Solution (By Examveda Team)

This MySQL statement is used to retrieve information about employees from a table called "employee".
Let's break down the statement:
SELECT emp_id, fname, lname FROM employee
This part selects the "emp_id", "fname" (first name), and "lname" (last name) columns from the "employee" table.
WHERE LEFT (lname, 1) =’F’
This is a condition that filters the results. Here's what it means:
* LEFT (lname, 1) : This function extracts the first character (1) from the "lname" column.
* = 'F': This compares the extracted character to the letter 'F'.
In simpler terms, the statement will only select those employees whose last name starts with the letter 'F'.
Therefore, the correct answer is Option A: Only those employees are selected whose last name started with 'F'.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous