Examveda

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

A. Single row

B. Double row

C. No row

D. None of the mentioned

Answer: Option A

Solution (By Examveda Team)

This MySQL command is designed to update information in a table named "person".
Let's break down the command:
UPDATE person : This part tells MySQL to modify data in the "person" table.
SET lname='s', Fname='p' : This part specifies the changes to be made. It sets the "lname" (last name) column to 's' and the "Fname" (first name) column to 'p'.
WHERE person_id=1 : This is crucial! It restricts the update to only the row where "person_id" equals 1.
Since "person_id" is a primary key, it uniquely identifies each row in the table. This means only one row can have "person_id=1".
Therefore, the correct answer is Option A: Single row.
The command will update only the row with the primary key "person_id" equal to 1.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous