?
What is the value of val2 in the following MySQL statement?
What is the value of val2 in the following MySQL statement?
UPDATE t SET val1 = val1 + 2, val2 = val1;
UPDATE t SET val1 = val1 + 2, val2 = val1;
Answer & Solution
Correct Answer:
Option
B
This MySQL statement uses the
SET val1 = val1 + 2: This part increases the value of the 'val1' column by 2.
SET val2 = val1; This part assigns the updated value of 'val1' to the 'val2' column.
So, the answer is Option B: updated val1.
The 'val2' column will be assigned the value of 'val1' after it's been increased by 2.
UPDATE command to modify the values in a table named 't'. Let's break down what's happening:
SET val1 = val1 + 2: This part increases the value of the 'val1' column by 2.
SET val2 = val1; This part assigns the updated value of 'val1' to the 'val2' column.
So, the answer is Option B: updated val1.
The 'val2' column will be assigned the value of 'val1' after it's been increased by 2.
Join the Discussion
Login to post a comment or share your explanation.
Login