SQL double join in python
<p>i have two tables, a and b each with many rows. 
i have an SQL code saying </p>

<pre><code>SELECT* FROM a INNER JOIN b ON (a.names = b.names) and (a.age = b.age)
</code></pre>

<p>im trying to make this in python using the .merge() function, and by making a mid-table from the first join and then trying to make it by joining that table to the next condition. but python pulls up an error </p>

<pre><code>join3 = a.merge(b,how='inner',left_on = 'name', right_on = 'name')
join4 = join3.merge(b,how'inner',left_on='age',right_on='age')
</code></pre>

<p>this gives a memory error:
ive tried to replicate this using various &amp; methods.
ive also tried this </p>

<pre><code>merge = a.merge(b[b.age==a.age],left_on= 'name', right_on='name')
</code></pre>

<p>im at a lose to what to do</p>

<pre><code>a.merge(b, how='inner', on=['name','age'])
</code></pre>

<p>and if say your column for ages in b had a different name say years, which mine did i did this</p>

<pre><code>b['age'] = b['years'] 
</code></pre>

<p>and then i could use the above.
i also could have renamed that column but wanted to keep all original columns there</p>

python mysql join