I'm trying to make a site where people can sign up for events + an activity assigned to that event. They can choose which one they want to attend, or even both.
For that I made a table named "eventCounter"
Image of table
userID, eventID and activityID are all FK poiting to other tables.
They should be able to update their current "status", so they can join the activity after they signed up for the event.
So my question is: How can I make a If else saying if row exists update else insert
IF EXISTS(select userID, eventID, activityID from eventCounter where userID=1 and eventID=1)
THEN
UPDATE eventcounter SET activityID=1 WHERE userID=1;
ELSE
INSERT INTO eventcounter (userID, activityID) VALUES(1,1)
I don't think the ON DUPLICATE key will work as I have 2 columns that needs to be checked?