2

I am using the following sql statement:

$sql = "INSERT INTO counter (uid, placeid, lastdate) VALUES
('" . $uid . "', '" . $place->place->id . "', '" . $added . "') 
ON duplicate KEY UPDATE count = count + 1`"; 

This keep tracks of how many times people check in. I do not want multiple check ins a day, so when if someone checks in twice a day we do not record it.

If $added = lastdate, I do not want to update the count.

Can this be done with a sql statement?

0

1 Answer 1

1

This should work:

"INSERT INTO counter (uid, placeid, lastdate) VALUES
('" . $uid . "', '" . $place->place->id . "', '" . $added . "') 
ON duplicate KEY UPDATE count = count + ('" . $added . "' <> lastdate)"
Sign up to request clarification or add additional context in comments.

1 Comment

no, that does not work. Maybe my variable name made it a little confusing. $added = the date of the check in. The count is getting incremented by one. So if $added = the value of lastdate then count is not incremented by one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.