You should check if the table exists. Have a look at dbDelta() to help with that.
There’s a lot more information in this post, so read through that and see what it suggests – https://codex.wordpress.org/Creating_Tables_with_Plugins
One thing that seems strange though… You say that you end up with 10 tables that are the saem… how is that possible? Do they at least have different names? MySQL will throw an error if you try to add a table that already exists.
@catacaustic I’ve used the wrong words, I mean there will be 10 identical ‘data’, not the table. Thanks for the reminder, I’ve updated the question. And I will have a look at the reference you have provided. Thank you so much!
@catacaustic I just realized that I’ve already read the reference you have provided in the past. It doesn’t mention the problem I’m asking about?…
If you’re checking for data then you will have to do that manually.
You can either check for the IDs or other primary keys that you are using, or set a flag that using set_option() to say that the initial data has been written.
OK I’m confused now.
What is being duplicated, and what do you want to stop? The database table or the data that you add to it?
If it’s the table, your link above is correct. dbDelta() will take care of that.
If it’s the data, then you need to have some sort of check to say if the data has been added previously so you can let your code decide to add it or not, as I said in my last comment above.
@catacaustic Sorry because I’m not good at explaining, but I found a quick solution:
https://wordpress.stackexchange.com/questions/369218/check-if-row-exists-before-inserting
By selecting the data and compare it with NULL.