Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
216 views

After Insert and Update Trigger on the same table

I have the following table in MySQL: CREATE TABLE `userlogtype` ( `UserLogTypeID` int NOT NULL AUTO_INCREMENT, `UserLogType` varchar(150) DEFAULT NULL, `InsertUser` varchar(100) DEFAULT NULL, `...
Steve Miller's user avatar
1 vote
0 answers
280 views

update trigger after insert on same table

So, I'm supposed to make a trigger that applies md5 to a row after an INSERT was made on it. Here is what I came up with: delimiter $$\ create trigger pd_encrip before insert on usuario\ for each row\ ...
Jade Fernandes's user avatar
0 votes
1 answer
2k views

MySQL Trigger to prevent update in one table if particular data is available in another table

I need a MySQL trigger that can prevent update of a particular column data, if some specific data is available in another table. I have two tables product and sales. Product Sale I need to prevent ...
PRAMOD MANN's user avatar
2 votes
2 answers
3k views

how to update one column with trigger mysql

i have 2 tables the first one is Table KEYS game keys WOW AAAAAAA-AAAAAAA-AAAAA WOW BBBBBBB-BBBBBBB-BBBBB L4D2 AAAAAAA-AAAAAAA-AAAAA TABLE inventory game country language pieces WOW USA EN 0 ...
Minioua's user avatar
  • 31
0 votes
0 answers
102 views

How to run both "before" and "after" update in trigger

I need to calculate prior values in a table before the column values are updated. Basically, I have to calculate the difference between the before the update and after update values. If there is any ...
BrownBatman's user avatar
1 vote
1 answer
1k views

How do you combine multiple update statements for the same row using MySQL trigger

Background: Each time a column is modified, I need to update the associated column (which has the same name) in a second table. This is my first attempt at using a trigger. Code: Here's a simplified ...
pbarney's user avatar
  • 171
0 votes
0 answers
58 views

Creating a trigger which stores updated value with old value in separate table

I'm trying to create a trigger which adds an old value to a table with the new value next to it. For example, if someone were to update their address, I'd like the trigger to add the old address to ...
MOwneZ's user avatar
  • 1
1 vote
1 answer
3k views

Can a MySQL trigger include a where clause

I need to create a trigger that, any time a goat's sireRegNo column is updated, its sireName column is automatically updated to match. I have a database that stores animal genealogy. Each row stores ...
donutguy640's user avatar
0 votes
1 answer
1k views

Pass parameter to trigger dynamically

I have a table on a mysql 5.7 db, containing say athletes with their mean, max, avg times in a specific sport. I have another table that lists some calculated statistics based on those values. I ...
pkaramol's user avatar
  • 211
-2 votes
1 answer
103 views

Simple Trigger Is Not Created in Mysql

I'm creating a trigger in mysql, but even with the correct syntax and the query being accepted the trigger is not created. If anyone can help. The following is the sql: DELIMITER $ CREATE TRIGGER ...
o2junior's user avatar
0 votes
1 answer
1k views

How do you perform a MYSQL After Update Trigger Insert Loop?

I have 3 mysql tables, one called batches, one called base_formula and one called raw_materials_stock. I want to perform an after update trigger on the batches table to insert information into the ...
Robert Low's user avatar
0 votes
2 answers
10k views

Why does this trigger slow down updates so much

I have a table. Lets call it table tableA. There's another table which keeps data about the history of tableA. Let's call that tableA_records. On tableA, there's a trigger on update which looks ...
dragmosh's user avatar
  • 105
-1 votes
1 answer
163 views

Mysql trigger on insert based on number match [duplicate]

I am using MySQL and I want a trigger on my table sms after every insert which will do the following: Update sms set provider = 'gp' where number like '88017%'; Update sms set provider = 'blink' ...
Ehsanul Karim's user avatar
0 votes
1 answer
7k views

MySQL Trigger to Update a Row in a Separate Table via Joins if Only One Row is Updated

I am trying to create a trigger so that when a column in a table called bookings is updated it will update a a calculated price value in table departments. I currently have my tables set up as so ...
JackGroves's user avatar
1 vote
1 answer
6k views

MySQL Using a trigger to update quantity on another table if part is used

I am new to triggers but want to know how I can use one in my database. I have created a table for a maintenance log, a parts inventory, and a parts_used junction table. When maintenance is carried ...
JackGroves's user avatar
0 votes
1 answer
5k views

MySQL Trigger On UPDATE "Unknown Column" Error

I want to log a table when it is updating a row in which the value of the "insertDate" or "updateDate" column is older than 3 months. I wrote this trigger: DELIMITER /// CREATE TRIGGER `...
Mesuti's user avatar
  • 141
1 vote
1 answer
7k views

mysql trigger / stored procedure - update another table row by row

I've already, searched and read, many answers about this issue for 3 days, but couldn't get a clear answer on how to do this. this will be a little long, be patient please. First of all, I am trying ...
Who Cares's user avatar
  • 187
0 votes
1 answer
251 views

Update Trigger in MYSQL

Here is my requirement :- I have a table called "users" and field called "Admin". Field "id" is primary key. Wants to update "Admin" field to "1" if id=1000; Tried this ,but not working.I tried "New"...
santhosh kumar's user avatar
28 votes
3 answers
59k views

Is it possible to modify an existing trigger definition in MySQL?

I am wondering if it is possible to update a trigger definition in MySQL. For example, I have a trigger T and I want to add some new functionality to it. My assumption is that I need to drop and ...
Alex's user avatar
  • 413
2 votes
1 answer
598 views

MySQL add few column exception for TRIGGER UPDATE FOR EACH ROW

How to effectively add column id, name exception for trigger: CREATE TRIGGER updated BEFORE UPDATE ON table1 FOR EACH ROW SET NEW.date=NOW() so that date=NOW() will be affected on updating any ...
Binyamin's user avatar
  • 121
1 vote
2 answers
128 views

how should i do this trigger?

I am a newbie to the sql world :) Right now i'm trying to create my first mysql trigger that would either update a row or insert a new one. Could you help me with that ? Here is the code : DELIMITER ...
daverck's user avatar
  • 33
3 votes
1 answer
4k views

Is there a workaround for lack of support of cascade triggers with MySQL?

As things stand, cascaded foreign key actions do not activate triggers with MySQL. I don't want to get into the debate as to whether or not this is good, I just would like to know whether there is a ...
Max's user avatar
  • 349
14 votes
3 answers
46k views

Trigger to UPDATE after UPDATE?

I want to make a trigger to record the time of any update as: CREATE TRIGGER col_update AFTER UPDATE ON col FOR EACH ROW BEGIN UPDATE col SET updated=NOW() WHERE id=NEW.id; // or OLD.id END The ...
Googlebot's user avatar
  • 4,531