The logic you are attempted is implemented using syntax like this:
INSERT INTO `categories` (`name`,`path`)
SELECT name, path
FROM (SELECT 'TEST 1' as name, 'test-1' as path UNION ALL
SELECT 'TEST 2', 'test-2' UNION ALL
SELECT 'TEST 3' , 'test-3'
) t
WHERE NOT EXISTS (SELECT 1
FROM categories c
WHERE c.name = t.name and c.path = t.path
);
However, you should be doing the checking in the database with a unique index. So the better solution is to do the insert and just have:
create unique index idx_categories_name_path on categories(name, path)
With an insert like:
INSERT INTO `categories` (`name`,`path`)
SELECT name, path
FROM (SELECT 'TEST 1' as name, 'test-1' as path UNION ALL
SELECT 'TEST 2', 'test-2' UNION ALL
SELECT 'TEST 3' , 'test-3'
) t
ON DUPLICATE KEY UPDATE name = VALUES(name);
insert ignore into ...to insert the data