SQL join third table
<p>So I have a three table setup that looks like the following...</p>

<p>Table 1 - reciept items</p>

<pre><code>ri_id | ri_name | ri_reciept 
----------------------------
1     | nails   | 1
2     | screws  | 1
3     | hammer  | 1
</code></pre>

<p>Table 2 - reciepts</p>

<pre><code>r_id | r_name   | r_mop
-----------------------
1    | reciept1 | 1
2    | reciept2 | 2
3    | reciept3 | 2
</code></pre>

<p>Table 3 - method_of_payment</p>

<pre><code>m_id | m_name
-------------
1    | Bank Transfer
2    | Cash
3    | Cheque
</code></pre>

<p>This is my SQL code im trying to run</p>

<pre><code>SELECT * FROM reciept_items ri 
INNER JOIN reciepts r ON ri.ri_reciept = r.r_id 
INNER JOIN method_of_payment mop ON r.r_mop = mop.m_id 
WHERE ri_reciept = :id
</code></pre>

<p>UPDATE: Last WHERE line works like follows...</p>

<pre><code>$queryRecieptItems = $dbh-&gt;prepare("
                SELECT * FROM reciept_items ri 
                INNER JOIN reciepts r ON ri.ri_reciept = r.r_id 
                INNER JOIN method_of_payment mop ON r.r_mop = mop.m_id 
                WHERE ri.ri_reciept = :id
            ");
            $queryRecieptItems-&gt;execute(array( "id"=&gt;$reciept['r_id'] ));
</code></pre>

<p>I'm trying to access the 'm_name' column while looping through Table 1, any ideas why the above doesn't work?</p>