MySQL : Create a function to compare the two conman separated values

CREATE FUNCTION `FIND_IN_TWO_SET`(val TEXT, val2 TEXT) RETURNS int(11)
BEGIN
        DECLARE output TEXT;
        DECLARE inc INT;
        DECLARE mach INT;
        SET inc = 0;
        SET mach = 0;
        
        label1: LOOP
            SET inc = inc + 1;
            SET output = REPLACE(SUBSTRING(SUBSTRING_INDEX(val, ',', inc), CHAR_LENGTH(SUBSTRING_INDEX(val, ',', inc - 1)) + 1), ',', '');
            IF output = '' THEN
                SET output = null;
                LEAVE label1;
            END IF;
            if find_in_set(output, val2) > 0 THEN
                SET mach = 1;
                LEAVE label1;
            END IF;
                ITERATE label1;
            END LOOP label1;
        RETURN mach;
    END

PHP : Import database

public static function updateDatabase($path){
ini_set(‘memory_limit’, ‘-1’);
ini_set(‘max_execution_time’,’-1′);
$em = $this->getEntityManager();
$fp = fopen ( $path, ‘r’ );
$fetchData = fread ( $fp, filesize ( $path) );
$sqlInfo = explode ( “;\n”, $fetchData); // explode dump sql as a array data
foreach ($sqlInfo AS $sqlData ){
$qb = $em->createQueryBuilder ();
$connection = $em->getConnection ();
$connection->executeQuery ( $sqlData);

}
}