there is a way in mysql / mariadb triggers to know if a value is present (set) in the update query?
For example:
create table MyTest (
col1 varchar(45),
col2 varchar(45)
);
insert into MyTest values ( 'val1','val2');
So when I execute
update MyTest set col1 = 'val1.1'
in the trigger I would like to know that col2 is not set.
Thank You
UPDATE (I changed also table schema for better explain my problem)
I have setup a trigger like this
CREATE DEFINER=`root`@`localhost` TRIGGER `MyTest_BEFORE_UPDATE` BEFORE UPDATE ON `MyTest` FOR EACH ROW
BEGIN
IF (NEW.col2 <=> OLD.col2) THEN
SET NEW.col2 = 'triggered';
END IF;
END
If I call
UPDATE MyTest set col1 = 'val1.3'
table will be (this is ok)
+------+---------+
|col1 | col2 |
+------+---------+
|val1.3|triggered|
+------+---------+
but if i call
UPDATE MyTest SET col1='val1.4',col2='val2.4'
first time table is ok
+------+---------+
|col1 | col2 |
+------+---------+
|val1.4|val2.4 |
+------+---------+
but a second update like this
UPDATE MyTest SET col1='val1.5',col2='2.4'
table will be:
+------+---------+
|col1 | col2 |
+------+---------+
|val1.5|triggered|
+------+---------+
instead i would like it should be
+------+---------+
|col1 | col2 |
+------+---------+
|val1.5|val2.4 |
+------+---------+
There is some way i can check this?
Thanks