In the database there is a table (my_table) with two columns ID and NAME. I want to make a procedure for INSERT / UPDATE. If a match is found - change the value, if not - add.
DELIMITER // CREATE PROCEDURE ins_upd (in x int(10), in y varchar(20)) begin if (x IN (SELECT ID FROM my_table) then UPDATE my_table SET ID=x, NAME=y; else INSERT INTO my_table values (x, y); end if; end// swears at the syntax, tell me what's wrong?