Answer the question
In order to leave comments, you need to log in
How to get rid of duplicate entries?
There are sl. Structure:
page_statistics id, page_id, date, visitors, ...
When a record is inserted into another table, a trigger is called to add/update (visitors + 1 if the record exists). The problem is that there are no unique fields in the structure, i.e. there may be different announcements for each day
For example:
1, 11, 10.04.2016, 117
2, 22, 10.04.2016, 172
3, 11, 12.04.2016, 56
4, 11, 13.04.2016, 32
CREATE TRIGGER `after_insert_page_visits` AFTER INSERT ON `page_visits`
FOR EACH ROW INSERT INTO `page_statistics` (page_id, date ,visitors, created) VALUES (NEW.page_id, UNIX_TIMESTAMP(CURDATE()), 1, UNIX_TIMESTAMP()) ON DUPLICATE KEY UPDATE visitors=visitors + 1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question