I want to insert multiple records or update those records if 2 specific column values do not exist in a record. But the 2 values are NOT UNIQUE, so I can not use ON DUPLICATE KEY. I am trying to not use IF...Then statements. It seems to be bad programming practice.
Here is the pseudo code of what I want to accomplish.
INSERT INTO interest_list (user_id, interest_id, details) VALUES (1, 1,'somestring1'), (1, 2, 'somestring2'), ...etc IF the record exists where (user_id==1 and interest_id==1) or (user_id==1 and interest_id==2) ... etc THEN (dont insert but rather update) UPDATE interest_list SET details = CASE interest_id WHEN 1 THEN 'somestring1' WHEN 2 THEN 'somestring2' ...etc END WHERE interest_id IN (1,2...etc) AND user_id=1;
Its fairly complicated to explain, hopefully someone gets my question. I am trying to accomplish this in 1 query.