title: Correct SQL table alias syntax in trigger with if statement
body: <p>So basically I'm trying to create a trigger that will update another table if an insert or update is located less than 1 meter of distance of an existing one. </p>
  
  <p>It does not allow me to insert anything because the FROM clause is missing on the if statement and I'm not sure how to call it properly.</p>
  
  <p>I got the following </p>
  
  <pre><code> CREATE TRIGGER access_node_aiu
   AFTER INSERT OR UPDATE
   ON schemab.table
   FOR EACH ROW
   EXECUTE PROCEDURE schemab.trigegr();
  
   CREATE OR REPLACE FUNCTION schemab.trigger()
   RETURNS trigger AS
   $BODY$
  BEGIN
  
      if st_distance(new.geom, a.geom) &lt; 1 then
  INSERT INTO schemab.overlap
  SELECT nextval('schemab.overlap_id_seq'::regclass), a.node_id, new.node_id, a.date, now(), st_distance(a.geom, new.geom), new.geom
  FROM schemab.table a;
  end if;
  
      RETURN new; 
  END;
  $BODY$
   LANGUAGE plpgsql VOLATILE
   COST 100;
  </code></pre>
  
  <p>How to do this in postgresql?</p>