How do I show duplicate values via ajax of textareas in mysql

Hi Australian Brothers, as I take all the textarea of the database and query with the current I’m editing, in change jquery mode and all of the database to show only the duplicate values. Note the current post I delete from the database query.

Note I have to get the post id and the post title of the duplicate value. And if it is possible to show the current post id and post title of the current textarea editing in case of duplicate

All help is welcome, since I thank you.

// No Duplicate Textarea Value
function no_duplicate_textarea_value_ajax_func() {
    global $wpdb;
    $current_var = $_POST['corrent_var'];
    $post_id = $_POST['post_id'];
    $separate_current_result_by_line_break = preg_split('/$\R?^/m', $current_var);

    $get_all_textarea_mysql = $wpdb->get_results($wpdb->prepare("SELECT pm.meta_value, pm.post_id, p.post_title FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts p ON p.ID = pm.post_id WHERE p.ID != '$post_id' AND pm.meta_key = 'all_textarea_save' AND p.post_status = 'publish' AND p.post_type = 'textearea_values'"));


    foreach ($get_all_textarea_mysql as $all_textarea_getting_only_one_per_loop) {

        $all_textarea_values_per_line_break = explode(PHP_EOL, $all_textarea_getting_only_one_per_loop->meta_value);
        foreach ($all_textarea_values_per_line_break as $individual_array_values) {
            $textarea_array_per_row[] = $individual_array_values;
        }

        // error between $separate_current_result_by_line_break and $textarea_array_per_row repeating in all loops so I want $separate_current_result_by_line_break to combine only once
        $combine_array_textarea = array_merge($textarea_array_per_row, $separate_current_result_by_line_break);

        $pick_up_only_the_duplicates = array_count_values($combine_array_textarea);

        foreach ($pick_up_only_the_duplicates as $duplicate_value => $if_count) {
            if ($if_count > 1) {
                echo 'Title Post Textarea: ' . $all_textarea_getting_only_one_per_loop->post_title;
                echo ' ID: ' . $all_textarea_getting_only_one_per_loop->post_id;
                echo ' duplicate value: ' . $duplicate_value . '<br><br>';
            }
        }
    }
    die();
}

You can use vanilla SQL:

SELECT  id, name FROM table 
WHERE id NOT IN (SELECT DISTINCT ON (name) id FROM table)

https://www.db-fiddle.com/f/eaQG8H4yqY9hnQBZjzJgz/26