title: Delete records from multiple table in postgres database sql script
body: <p>I have a scenario as below.</p>
  
  <p>I have five tables: <code>merchants</code>, <code>user_details</code>, <code>user_role</code>, <code>transient_payments</code> and <code>payments</code>.</p>
  
  <p>Requirements: if merchant_id does not exist in transient_payments and payments table then that merchant should be deleted from <code>merchants</code>, <code>user_details</code>, <code>user_role</code></p>
  
  <p>My Query : </p>
  
  <pre><code>DELETE FROM m,ud,ur USING merchants 
         INNER JOIN user_details 
         INNER JOIN user_role 
         where merchant_id not 
         exists (select * 
                 from transient_payments 
                 full join payments 
                 on transient_payments.merchant_id = payments.merchant_id );
  </code></pre>
  
  <blockquote>
  <pre><code>Error :ERROR:  syntax error at or near "," LINE 1: DELETE FROM m,ud,ur
  USING merchants INNER JOIN user_details ...
                      ^
  
  ********** Error **********
  ERROR: syntax error at or near "," SQL state: 42601 Character: 14
  </code></pre>
  </blockquote>