Examveda

In the following MySQL command how many rows will be updated?
UPDATE person
SET lname=’s’,
Fname=’p’,
WHERE person_id<10;
/* person_id is a primary key */

A. 0-9

B. 1-6

C. No row

D. None of the mentioned

Answer: Option A

Solution (By Examveda Team)

This question is asking about the number of rows that will be updated in a MySQL database using the provided command. Let's break it down:
UPDATE person: This tells us we're modifying data within the 'person' table.
SET lname='s', Fname='p': This part assigns the value 's' to the 'lname' column and 'p' to the 'fname' column for each row that meets the criteria.
WHERE person_id<10: This is a condition that specifies which rows will be affected. It says that only rows where the value in the 'person_id' column is less than 10 should be updated.
/* person_id is a primary key */: This comment tells us that 'person_id' is a primary key. A primary key uniquely identifies each row in a table.
Since a primary key can't have duplicate values, having a 'person_id' less than 10 means there are at least 10 rows in the table.
Therefore, the correct answer is: Option A: 0-9
The command will update all rows in the 'person' table where the 'person_id' is less than 10. The exact number of rows updated will depend on how many rows have a 'person_id' less than 10.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous