Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

MYSQL - Inserir se a tabela estiver vazia

INSERT INTO `account_types`(`type`, `group`)
SELECT * FROM
(SELECT '400' `type`, 'test' `group` UNION ALL
 SELECT '401' `type`, 'test2' `group` UNION ALL
 SELECT '402' `type`, 'test3' `group`) A
WHERE NOT EXISTS (SELECT NULL FROM account_types B WHERE A.type=B.type);

Demonstração