INSERT INTO blockedip (userIP) SELECT userIP FROM users WHERE os LIKE 'and' AND userIP !='' group by userIP having count(*) > 3;