Inserting only unique into MySQL
Posted on 2004-09-11
I want to build a table in mysql of all of the unique url's that are accessing my script. I don't want to do an INSERT for every record, as that will cause double records to be formed. Is setting the table field which will hold the url as a primary key the way to do this? I think mysql generates an error if you try to insert a duplicate primary key, so this doesn't feel like the most elegant way to build a table that contains only one of each value. I'd like to avoid having to do a table lookup and then an insert, if possible.