tags:

views:

20

answers:

1

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?

+1  A: 

This should work:

"INSERT INTO counter (uid, placeid, lastdate) VALUES
('" . $uid . "', '" . $place->place->id . "', '" . $added . "') 
ON duplicate KEY UPDATE count = count + ('" . $added . "' <> lastdate)"
Mark Byers
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
John