When multiple records are inserted in batches, one insertinto inserts multiple identical records. when multiple insert records are inserted in batches, one insert into inserts multiple identical records from time to time. what is the situation.
How should we solve this problem?
Reply to discussion (solution)
Please post the code !!!
Whether or not to repeat each time when batch addition is performed. If yes, check the code.
For ($ I = 0; $ I <$ s; $ I ++ ){
$ Iaps = $ iap [$ I];
$ Daqs = $ daq [$ I];
$ Row = mysql_query ("select count (*) from 'dls' where 'iap '=' $ iaps '"); // check whether duplicate data exists.
$ Row = mysql_fetch_row ($ row );
If ($ row [0]) {continue ;}
Mysql_query ("insert into 'dls' ('iap ', 'dash', 'KT') value ('$ iaps', '$ daqs', 'KT ')");
}
Loop problems.
1. it is best to solve the loop.
2. create a UNIQUE index for a field to avoid repeated inserts.
2. use the insert into from dual where not exists statement to avoid repeated inserts.
Insert into [table name] SELECT '[value1]', '[value2]' FROM DUAL
Where not exists (
SELECT [column1] FROM [same table name]
WHERE [column1] = '[value1]'
AND [column2] = '[value2]' LIMIT 1
)
It is best to use transactions to ensure consistency.
$ Row = mysql_fetch_row ($ row );
Var_dump ($ row); print the result.