I have 2 columns date
(primary) and user_id
(unique). I want to check if the row exists if not create it, if so update the row for that day.
for example: if a user updates the database multiple times a day I only want 1 record created per day and that record to update every time the user updates the database. However if the same user(same user_id) updates the database the next day I want a new record created.
I'm using the following code:
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
The problem is it doesn't appear to be checking for both date
AND user_id
but only the user_id. How can I get it to check for both? Thanks.