mysql-error-1442

MySQL after update, update datetime column of same table

故事扮演 提交于 2021-01-05 05:18:06
问题 I have a table called teamMembers , this table stores a name and an e-mail address of a person: id INT (UNIQUE, AUTOINCREMENT) name VARCHAR(255) email VARCHAR(255) updated DATETIME created TIMESTAMP I've created my trigger using phpMyAdmin and it looks like this in this export: CREATE TRIGGER teamMembers.updated_updater AFTER UPDATE ON teamMembers FOR EACH ROW BEGIN UPDATE teamMembers SET updated = NOW() WHERE id = OLD.id; END So when I use a query like this: UPDATE teamMembers SET name =

MySQL after update, update datetime column of same table

时光毁灭记忆、已成空白 提交于 2021-01-05 05:01:09
问题 I have a table called teamMembers , this table stores a name and an e-mail address of a person: id INT (UNIQUE, AUTOINCREMENT) name VARCHAR(255) email VARCHAR(255) updated DATETIME created TIMESTAMP I've created my trigger using phpMyAdmin and it looks like this in this export: CREATE TRIGGER teamMembers.updated_updater AFTER UPDATE ON teamMembers FOR EACH ROW BEGIN UPDATE teamMembers SET updated = NOW() WHERE id = OLD.id; END So when I use a query like this: UPDATE teamMembers SET name =

MySQL after update, update datetime column of same table

帅比萌擦擦* 提交于 2021-01-05 05:01:05
问题 I have a table called teamMembers , this table stores a name and an e-mail address of a person: id INT (UNIQUE, AUTOINCREMENT) name VARCHAR(255) email VARCHAR(255) updated DATETIME created TIMESTAMP I've created my trigger using phpMyAdmin and it looks like this in this export: CREATE TRIGGER teamMembers.updated_updater AFTER UPDATE ON teamMembers FOR EACH ROW BEGIN UPDATE teamMembers SET updated = NOW() WHERE id = OLD.id; END So when I use a query like this: UPDATE teamMembers SET name =

#1442 - Can't update table '*' in stored function/trigger because it is already used by statement which invoked this stored function/trigger

眉间皱痕 提交于 2020-07-30 09:06:50
问题 I'm really bad at SQL, but I'm trying to keep my database simple and minimalistic as possible. Not duplicating values but using references and id's instead. Now after inserting a query I get error 1442 - Can't update table 'signed' in stored function/trigger because it is already used by statement which invoked this stored function/trigger Query can be inserted when the trigger is disabled. But my query is only reading from table 'users' so there should not be a conflict. I read something

Find node level in a tree

不羁的心 提交于 2020-01-13 09:28:14
问题 I have a tree (nested categories) stored as follows: CREATE TABLE `category` ( `category_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `category_name` varchar(100) NOT NULL, `parent_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`category_id`), UNIQUE KEY `category_name_UNIQUE` (`category_name`,`parent_id`), KEY `fk_category_category1` (`parent_id`,`category_id`), CONSTRAINT `fk_category_category1` FOREIGN KEY (`parent_id`) REFERENCES `category` (`category_id`) ON DELETE SET NULL ON UPDATE

MySQL: How to create trigger for setting creation date for new rows

假如想象 提交于 2019-12-30 00:35:12
问题 I ran into a problem as I tried to create two TIMESTAMP columns in my database. One called created and one called updated . I figured it would be easy to set the default value of both to CURRENT_TIMESTAMP and then ON UPDATE CURRENT_TIMESTAMP for the updated column. But for some reason MySQL means that's a bad idea... so I have been looking for ways to do this without having to set one of them in the insert query. I found one way by using a trigger in this answer, but I keep getting errors. I

ERROR 1442: Can't update table in stored function/trigger because it is already used by statement which invoked this stored function/trigger

China☆狼群 提交于 2019-12-23 22:27:59
问题 I have a table that I want : when the table has been updated, 2 fields of that (title and description) change and take value from another table This is my trigger: drop trigger trigger_trade_request ; CREATE TRIGGER trigger_trade_request AFTER UPDATE ON `trade_request` FOR EACH ROW BEGIN IF NEW.title = null THEN UPDATE `trade_request_type`,`trade_request` SET NEW.title = `trade_request_type`.title , NEW.description = `trade_request_type`.description WHERE `trade_request_type`.id = NEW.trade

what is the real cause of mysql error 1442?

余生颓废 提交于 2019-12-17 10:01:49
问题 well i have looked for a lot of places on the internet for the cause of the mysql error #1442 which says Can't update table 'unlucky_table' in stored function/trigger because it is already used by statement which invoked this stored function/trigger some say that this is a bug in mysql or a feature that it doesnt provide. MySQL triggers can't manipulate the table they are assigned to. All other major DBMS support this feature so hopefully MySQL will add this support soon. Some claim that this

mysql trigger stored trigger is already used by statement which invoked stored trigger

家住魔仙堡 提交于 2019-12-17 05:11:49
问题 I want to set up a trigger so that if on an update the prediction field is = 3 then the trigger changes the value to 4 and saves it in the database. The trigger is below. For some reason I keep getting an error saying: #1442 - Can't update table 'tzanalytic\_forecast\_cached' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. Is this set up the right way? delimiter $$ CREATE TRIGGER no_BoW BEFORE UPDATE ON t FOR EACH ROW BEGIN set

Mysql can't update rows when my trigger is called

偶尔善良 提交于 2019-12-12 00:46:53
问题 My trigger fails when i try to insert a new row in my table because Mysql doesn't support updating rows in the same table the trigger is assigned to. Does anyone have suggestions on a good workaround/alternative? My trigger: -- Trigger DDL Statements DELIMITER $$ CREATE TRIGGER check_sequence BEFORE INSERT ON data FOR EACH ROW BEGIN IF EXISTS(SELECT TRUE FROM data WHERE sequence = NEW.sequence) THEN UPDATE data SET sequence=sequence+1 WHERE sequence >= NEW.sequence; END IF; END $$ DELIMITER ;