I am trying to create a trigger that updates one field in a table different from the one being updated/inserted.

My create trigger code looks like this:

CREATE TRIGGER before_insert_ddsw BEFORE INSERT ON `ddsw` 
FOR EACH ROW SET products.count - products.count +1;

When I try to create this I get an error #1193 - Unknown system variable 'count' but there is definately a field called 'count' in the product table.

What am I missing here?

Thanks!

Recommended Answers

All 5 Replies

You have a - where there should be an =.

CREATE TRIGGER before_insert_ddsw BEFORE INSERT ON `ddsw`
      FOR EACH ROW SET products.count = products.count +1;

You have a - where there should be an =.

CREATE TRIGGER before_insert_ddsw BEFORE INSERT ON `ddsw`
      FOR EACH ROW SET products.count = products.count +1;

Yeah, that was a definate typo on my part but it didnt change the error message... I would have thought this would be a simple one.

I hate to use the mysql forums but I may have to on this one... dangit!

CREATE TRIGGER before_insert_ddsw BEFORE INSERT ON `ddsw` 
FOR EACH ROW SET products.count - products.count +1;
DELIMITER //

CREATE TRIGGER before_insert_ddsw BEFORE INSERT ON `ddsw` 
FOR EACH ROW 
BEGIN
UPDATE ddsw SET products.count - products.count +1; 
END //

DELIMITER ;

Ah, that makes sense. Glad you solved it!

Ah, that makes sense. Glad you solved it!

Yeah, that one was really bugging me... it was primarily that update command... I guess you gotta select the table in which you want to set a field! LOL

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.