如果值不在数组中,则从表中删除

My code is writing from an array "Value1,Value2,Value3" to the table:

+----+--------+
| ID |  Value |
+----+--------+
|  1 | Value1 |
+----+--------+
|  2 | Value2 |
+----+--------+
|  3 | Value3 |
+----+--------+

I am using a bootstrap Tag field and when I remove Value2, the array changes to "Value1,Value3" but does not delete the Value2 in the database table.

How do I check and remove Value2?

This is my current code:

$commaList = explode(', ', $support_membership);

            foreach ($commaList as $value) {
                $sql = "select * from groups where value like '$value' ";
                $rs = mysqli_query($database, $sql);
                if (!$rs) error_dlg(mysqli_error($database));

                if(mysqli_num_rows($rs) == 1){
                    //do nothing
                } else {
                    $sqlgroup = "insert into groups set ";
                    $sqlgroup .= "system='2', ";
                    $sqlgroup .= "value='$value' ";
                    mysqli_query($database, $sqlgroup);
                }