How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table

  1. UPDATE Persons SET LastName='Hansen' WHERE LastName='Nilsen'

  2. MODIFY Persons SET LastName='Hansen' WHERE LastName='Nilsen'

  3. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

  4. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'


Correct Option: C
Explanation:

To change "Hansen" into "Nilsen" in the "LastName" column in the Persons table, the user needs to use SQL UPDATE statement.

UPDATE statement is used to modify the existing records in a table.

Now, let's go through each option:

A. UPDATE Persons SET LastName='Hansen' WHERE LastName='Nilsen': This option is incorrect because it will change the LastName to "Hansen" where LastName is "Nilsen". This will not change "Hansen" to "Nilsen".

B. MODIFY Persons SET LastName='Hansen' WHERE LastName='Nilsen': This option is incorrect because MODIFY is not a valid keyword in SQL. Also, this statement will change LastName to "Hansen" where LastName is "Nilsen". This will not change "Hansen" to "Nilsen".

C. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen': This option is correct because it will change LastName to "Nilsen" where LastName is "Hansen". This will change "Hansen" into "Nilsen" in the LastName column.

D. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen': This option is incorrect because MODIFY is not a valid keyword in SQL. Also, this statement will change LastName to "Nilsen" where LastName is "Hansen". This will change "Hansen" into "Nilsen" in the LastName column.

The Answer is: C

Find more quizzes: