I need to keep a running count of actions for particular dates, so I need to say 'if this date & value aren't in the table, insert them. if they are, increment them'. Is this possible to do in 1 query? I can't figure how.
Here's what I'm doing at the minute:
SELECT count(*) FROM tracking
WHERE date = current_date() AND source = 'somesource'
AND target = 'sometarget'
ahh i dont understand u.....my question is ,on duplicate key is available in version 4? if yes u dont ned to concatenate the string. the only things to remember is the filtering expression. ex i have table below and its field.
the concatenating the string was purely to create a unique key.
There had to be 1 entry unique to a date/source/target combination. I read in the manual that keys on duplicate fields was not advised using ON DUPLICATE KEY UPDATE, so I did a hack job and created a unique field with a combination of the other fields.
As for availability in 4.0, either i'm wrong about that, or i'm wrong about what version i'm using!