Воспользуйтесь ограничителем UNIQUE по языку и это вашему ID:
ALTER TABLE `table_name` ADD UNIQUE (`language`, 'ID');
UPDATE: вот примерный код для управления полем ID при записи страниц в виде хранимой процедуры:
DELIMITER ;
DROP PROCEDURE IF EXISTS createLocalizedPage;
DELIMITER $
CREATE PROCEDURE createLocalizedPage(
IN language_in VARCHAR(20),
IN image_path_in VARCHAR(120),
IN page_content_in LONGTEXT
) SQL SECURITY INVOKER
BEGIN
DECLARE var_page_unique_id INT;
START TRANSACTION ;
IF (exists(SELECT 1 from `table_name` where image_path = image_path_in)) THEN
SET var_page_unique_id = (select max(`ID`) + 1 from `table_name`);
ELSE
SET var_page_unique_id = (select `ID` from `table_name` where image_path = image_path_in);
END IF;
INSERT INTO `table_name` (`language`, `image_path`, `page_content`, `ID`) VALUES
(language_in, image_path_in, page_content_in, var_page_unique_id);
COMMIT ;
END $
DELIMITER ;
Или вставить одним запросом:
INSERT INTO `table_name` (`language`, `image_path`, `page_content`, `ID`)
VALUES (
language_in,
image_path_in,
page_content_in,
CASE
WHEN exists(SELECT 1 from `table_name` where image_path = image_path_in) then
(select `ID` from `table_name` where image_path = image_path_in)
ELSE
(select max(`ID`) + 1 from `table_name`)
END
);