$array_with_ids = array('123', '124', '125');
$sql_ids = implode(',', $array_with_ids);
// Select friends already added to db
mysql_query("SELECT * FROM fb_users WHERE fb_id IN (".$sql_ids.")");
// Find friends, that are in your db, but not in the array
mysql_query("SELECT * FROM fb_users WHERE fb_id NOT IN (".$sql_ids.")");
foreach($array_with_ids AS $fb_id)
{
// Add new friends
mysql_query("INSERT IGNORE INTO fb_users VALUES (".$fb_id.", ".$name.", ".$stuff.")";
}
必ずfb_idのプライマリインデックスを使用してください