I want to add a lot of lines in my mysql database. And for each of those lines I need to do a search in the database. I will describe how I am doing it right now, but there must be a better way for this.
In a while loop I loop trough an array in which I have the data for that I need to insert the values for value1, value2, value3.
Then I do a SELECT id FROM table WHERE column='value3';
And after that I INSERT INTO insertTable VALUES (value1, value2, id);
This method results in a lot of queries. A possible improvement could be to instead of queuing the inserts, put the insert values in a array again and create a multi insert at the end. But there are still a lot of SELECT queries.
Any clues how to improve this?
Aucun commentaire:
Enregistrer un commentaire