I have a table with 2 columns, they are 'user' and 'action' and are used to denote when a user has completed a certain action. An entry should only be made if a user has not made the given action before so I feel something like the following is what is required:
IF NOT EXISTS (select * from actiontable WHERE user=1 and action=5) THEN
INSERT INTO actiontable VALUES(1,5);
Yet this seems to be incorrect syntax and I can't find how I should go about this. Is this possible? Or is there some way to use a primary key or unique key to achieve this?
ifin the context of a stored procedure, function, or trigger.