I have a PHP array and I want to insert from this array the items that are not already in MySQL table. After searching i could do this item by item using the following code
INSERT INTO `rtusers` (`Status`, `MSISDN`)
SELECT * FROM (SELECT 0, '966111111111') AS tmp
WHERE NOT EXISTS (
SELECT `MSISDN` FROM rtusers
WHERE MSISDN = '966111111111' ) LIMIT 1;
but the problem is i have hundreds of items in the array. if i used this code as a loop this will make hundreds of hits to the database. Does anybody have an easier solution?