Good day. There is a table:

CREATE TABLE buffer ( id INT PRIMARY KEY AUTO_INCREMENT, ad_type varchar(20), price varchar(20), description varchar(1000), params varchar(500), image varchar(300), ins_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); 

As well as the table source tbl_temp with fields type, price, comments, house, level, photo. Trying to make a trigger:

 CREATE TRIGGER 'update_tbl' AFTER INSERT ON 'tbl_temp' FOR EACH ROW BEGIN INSERT INTO buffer SET ad_type = NEW.type, price = REPLACE(NEW.price, 'руб.',''), description = NEW.comments, ad_params = CONCAT(NEW.house, ' ', level), image = NEW.photo END; 

I get the error:

 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''update_tbl' AFTER INSERT ON 'tbl_temp' FOR EACH ROW BEGIN INSERT IN' at line 1 

I realized that there was an error in INSERT, but that’s where I didn’t figure it out. Could you help me?
Thank!

Closed due to the fact that off-topic participants cheops , aleksandr barakin , Alex , fori1ton , user194374 Nov 29 '16 at 6:27 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - cheops, aleksandr barakin, Alex, fori1ton, Community Spirit
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • You do not have a semicolon after the insert statement. - cheops
  • Similar error: INSERT INTO buffer (ad_type, price, description, ad_params, image) VALUES (NEW.type, REPLACE (NEW.price, 'rub.', ''), NEW.comments, CONCAT (NEW.house, '' , NEW.level), NEW.photo); Comma is the same. - balamutik
  • one
    @Mike Especially for you climbed into the directory. SET is used in INSERT. dev.mysql.com/doc/refman/5.5/en/insert.html - balamutik
  • @balamutik Yes, I got excited about SET, mysql apparently has the only such form of insert ... And in your trigger, an error is possible in that the name of the trigger and the table are enclosed in single straight quotes. The names of tables and fields in MySQL are written in reverse apostrophes (usually to the left of 1 on the keyboard), or without them. - Mike

1 answer 1

The whole problem was in BEGIN and END. Removed them and the trigger was created.