title: PostgreSQL Trigger and rows updated
body: <p>I am trying to update a table according to this trigger:</p>
  
  <pre><code>CREATE TRIGGER alert 
  AFTER UPDATE ON cars
  FOR EACH ROW
  EXECUTE PROCEDURE update_cars();
  </code></pre>
  
  <p>Trigger Function :</p>
  
  <pre><code>CREATE FUNCTION update_cars()
  RETURNS 'TRIGGER' 
  AS $BODY$
  BEGIN 
  IF (TG_OP = 'UPDATE') THEN
  UPDATE hello_cars SET status = new.status 
  WHERE OLD.ID = NEW.ID;
  END IF;
  RETURN NULL;
  END;
  $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>The trigger works fine. When the <code>cars</code> table is updated, the <code>hello_cars</code> table is updated but the status column in each row is updated and contains same new status! It must be updated according to a car ID.<br>
  I think my problem is in condition: <code>WHERE OLD.ID = NEW.ID;</code> but I can't tell what's wrong.</p>
  
  <p>Thanks in advance.</p>