On UPDATE query I would like to change need_parse attribute if url attribute was changed. need_parse depends on url value.
How can I achieve this on MySQL & Python?
On UPDATE query I would like to change need_parse attribute if url attribute was changed. need_parse depends on url value.
How can I achieve this on MySQL & Python?
Perhaps you need something like:
UPDATE tbl
SET need_parse = CASE WHEN url = <input url> THEN need_parse ELSE <value to change to> END
You can use the following trigger to put check on updates. It will do what you require
DELIMITER $$
CREATE
TRIGGER `test`.`update_check` BEFORE UPDATE
ON `db_name`.`table_name`
FOR EACH ROW BEGIN
IF (new.`url` = old.`url`)
THEN SET new.`need_parse` = old.`need_parse`;
END IF;
END$$
DELIMITER ;
Hope it helps...