I am working on a project that scrapes contact information from multiple sources and inserts that data into an SQL table. For better context, I currently pull each source's data separately using the methods described here - How do I account for missing xPaths and keep my data uniform when scraping a website using DOMXPath query method?.
Because the number of contacts has the potential of changing, I decided to clear the table completely before adding the first source's data. Every subsequent source's data is added by using this statement before insertion - DELETE FROM people WHERE newsstation='NBC San Diego'
.
To keep the auto-increment column from starting its count on the number last generated, I set the first source's data to TRUNCATE TABLE people
before inserting the data. Now that I have multiple sources being added to the table, I have changed the first data source's clearing method from TRUNCATE TABLE people
to DELETE FROM people WHERE newsstation='San Diego CW 6'
.
The problem is, whenever I update any of these sources in the future, the auto-increment column continues counting from the last number generated rather than the MAX number found in the auto-increment column.
Is there any way to effectively TRUNCATE the auto-increment column only and insert a new set of numbers starting from 1? I was even wondering if there is a way for me to just delete the auto-increment column and add a new auto-increment column to resolve this?
I know there are a lot of similar questions on this site, but after searching at great lengths to find an answer for this problem, none of the methods I found worked for this particular situation.