title: MYSQL Inner join for three to four tables
body: <p>Please I need to figure out what I am doing wrong. I created this inner join code for mysql. it works but it gives me repeated values like repeating a particular row twice or categoryid twice. each of the tables(users,paymentnotification,monthlyreturns) has the categoryid used to check and display the username(users.pname) from the user table, then check and display those that have made payment from the monthly returns and payment table using the categoryid.</p>
  
  <pre><code>$r="SELECT monthlyreturns.categoryid, monthlyreturns.month, monthlyreturns.quarter, monthlyreturns.year,paymentnotification.amount, users.pname, monthlyreturns.ototal, paymentnotification.payee, status
  FROM paymentnotification 
  INNER JOIN (monthlyreturns INNER JOIN users ON monthlyreturns.categoryid=users.categoryid) 
  ON monthlyreturns.categoryid=paymentnotification.categoryid 
  ORDER BY monthlyreturns.categoryid DESC";
  </code></pre>