I’m trying to create a page that tracks some basic user statistics in a database. I’m starting small, by trying to keep track of how many people come using what User Agent, but I’ve come across a stumbling block. How can I check the User Agent being added to the table to see if it is already there or not?
Share
You can make the column that stores the User Agent string
unique, and do INSERT … ON DUPLICATE KEY UPDATE for your stats insertionsFor the table:
You could use the following query to insert user agents:
Executing the above query multiple times gives: