I made a parser that every 30 minutes takes ads from the real estate forum and writes them to the MySQL database. But now there are many duplicate records in the database. Next, I made a table in which the ad uniq field is saved. A unique value is written there, for example, showthread.php? S = 4ad705f976ce73fb739b76820a3a573f & t = 1485914 (the last 7 digits of each ad are unique!). Tell me, please, how is it better for me, now, to organize an ad test for uniqueness? Thanks in advance for any help.
For example, read UNIQUE KEY and INSERT IGNORE tutorials ...
Posha towards ON DUPLICATE KEY.
And what's stopping you from simply recording the ad id from the address bar?
immediately - t = this is most likely the ID of the ad, which is unique. According to him and check.
It is best to organize this check by the DBMS. Declare a primary key (a field or set of fields that completely defines a record and cannot be NULL) or a uniqueness constraint (field values that are not equal to NULL cannot be repeated, but equal ones can :)). But first you need to remove duplicates.
You can add a constraint like this: ALTER TABLE myTable ADD CONSTRAINT constraintName UNIQUE (mycolumn);