how can i write a trigger that compare between two tables in phpmyadmin mysql I have two tables that has rows that have same values.  

I want to write a trigger that will check for mypin in debtors tables and if mypin exists in debtors it fills the debtor row in the users table to have a value of 1 and if mypin does not exist in debtors table it fill the debtor row in users table to be 0.

debtors table
`debtor`, `myPIN`,



Users table
 `debtor`,`myPIN`



A db&lt;>fiddle can be found here
Here's one example. You should make deptor and mypin 
columns not null, or you will have to deal with possible nulls there:

delimiter //
create trigger before_insert_users
before insert on users
for each row
begin
    IF ( EXISTS (
            SELECT 1 FROM debtors
            WHERE debtors.myPIN = NEW.myPIN
         )
    )    
    THEN
        SET NEW.debtor = 1;
    ELSE
        SET NEW.debtor = 0;
    END IF;
end //


Note that you will need a delete trigger on debtor as well (if myPIN can change you need an update trigger in each table as well.