I need to update a statistics table through out the day. I would like
to insert the first data sampling of the data, then update the
existing record for the rest of the day. The problem is that I do not
alway know when the first sampling will start.
Keys for the table are username and date. So each user will have only
one entry per day.
I have been checking to see if the record exists - select .. where
username=... AND date =.... Seems like there is a better way.
I found the 'ON DUPLICATE KEY' in the mysql manual. Just can not get
this to work with PHP.
Sample would be.
INSERT INTO usagestats (username, date, usageinfo)
VALUES(username = 'jon', date = '2003-09-19', useageinfo='250315')
ON DUPLICATE KEY UPDATE usageinfo = '250315'
In this case if the record with username='jon' and date='2003-09-19'
already exists, then the ON DUPLICATE KEY would update this record
with usageinfo = '...'
What am I missing?
jtw
--
http://www.UsenetRocket.com