Why transaction blocking simple insert in MySQL? transaction Query
    mysqli_begin_transaction($conn);
    $sql = &quot;UPDATE foldertable SET trashed = 1 WHERE serverToken = (SELECT serverToken from servertoken where userToken = ? limit 1) and 
    
    (folderId = ?
    or 
    RootFolderPath LIKE 
                CONCAT (
                    (SELECT RootFolderPath FROM foldertable WHERE serverToken = (SELECT serverToken from servertoken where userToken = ? ) AND folderid = ? limit 1)
                    ,'/'
                    , ?
                    ,'%'

                )
    )&quot;;
    $stmt =  mysqli_stmt_init($conn);
    mysqli_stmt_prepare($stmt, $sql);
    mysqli_stmt_bind_param($stmt, &quot;sisii&quot;, $data[&quot;userToken&quot;], $id, $data[&quot;userToken&quot;], $id, $id);
    if (!mysqli_stmt_execute($stmt)) {
        echo mysqli_stmt_error($stmt);
        $serverError = true;
        return;
    }
    // echo &quot;\n\n affected rows &quot; . mysqli_affected_rows($conn);
    if (mysqli_affected_rows($conn) &gt; 0) {
        sleep(15);
        // Insert into bin folder
        $sql = &quot;INSERT INTO binfolder (serverToken , folderId) value ( (SELECT serverToken from servertoken where userToken = ? limit 1) , ?)&quot;;
        $stmt =  mysqli_stmt_init($conn);
        mysqli_stmt_prepare($stmt, $sql);
        mysqli_stmt_bind_param($stmt, &quot;si&quot;, $data[&quot;userToken&quot;], $id);
        if (!mysqli_stmt_execute($stmt)) {
            echo mysqli_stmt_error($stmt);
            $serverError = true;
            return;
        }
        if (mysqli_affected_rows($conn) &gt; 0) {
            $success = true;
            mysqli_commit($conn);
        }

    }

Insert Query
INSERT INTO foldertable(serverToken) SELECT (123456) 

Problem
if execute the insert query  after transaction started but the insert does not have to wait for transaction complete . Because the update query on transaction does lock row involved with insert query.
What I wanted
the Insert query will run immediately if it does not contain the same serverToken needed in Insert query.
Thank You in Advance.
For transaction blocking, the first line of defense is to speed up the query.  Though this does not completely eliminate the possibly of block/delay/deadlock, it will often make the situation more tolerable.
Re the LIMIT 1 -- Is there only 1?  If so, why not do a JOIN.  Or might there be more than one?  If so, which one?  That is, don't you need an ORDER BY?
servertoken needs INDEX(userToken, serverToken)
Would a single INSERT ... ON DUPLICATE KEY UPDATE ... suffice for your lengthy set of queries?  If so, it would probably be a lot faster.
I see an OR in the long query.  This is likely to prevent usage of an index.  (I don't understand the intent of the query well enough to suggest an alternative.)
&quot;RootFolderPath LIKE CONCAT (...&quot; -- This smells like something that should be redesigned.  Consider putting path parts in separate columns?  Or something else.
Is folderId the PRIMARY KEY of folderTable?
Plese provide SHOW CREATE TABLE (as text, not image) for each relevant table.