MySQL NEW keyword

4.2k Views Asked by At

I have what seems like a basic question, but I have been unable to find the answer. Does the NEW keyword in MySQL refer to what the row will look like after the given action is performed or does it only refer to actual values used in the query? For example:

Say I have a table sample with columns A int(6), B varchar(10), and C varchar(10). This table has one row (1, "hello", "world"). If I then perform an update:

UPDATE TABLE sample
SET C = "bob"
WHERE A = 1;

If I had an after update trigger I would expect the value of NEW.C to be "bob" but will the value of NEW.B be "hello" or null?

1

There are 1 best solutions below

0
sefy On BEST ANSWER

Value of NEW.C would be hello. You can also get the previous value (before the update) by using OLD.