INSERT INTO document_control SELECT CONCAT_WS('-', RIGHT(YEAR(CURRENT_TIMESTAMP), 2), LPAD(COUNT(*) + 1, 3, 0)) FROM document_control WHERE LEFT(id_custom, 2) = RIGHT(YEAR(CURRENT_TIMESTAMP), 2)