title: MySQL join 1 record in table A to many in table B as a single row
body: <p>I want to query across two tables: <strong>members</strong> and <strong>payments</strong>.</p>
  
  <p><em>One</em> member record could join with <em>many</em> payments. However, I need each payment record to be added as an <strong>additional column</strong> as opposed to an additional row.</p>
  
  <p>Here is a simplified example:</p>
  
  <h2>members</h2>
  
  <pre><code>member_id | first_name | last_name
  5         | John       | Smith
  </code></pre>
  
  <h2>payments</h2>
  
  <pre><code>payment_id | member_id | pay_type   | amount
  1          | 5         | VISA       | $20
  2          | 5         | Mastercard | $40
  3          | 5         | AMEX       | $10
  </code></pre>
  
  <h2>Desired query result</h2>
  
  <pre><code>member_id | first_name | last_name | payment_id1 | pay_type1 | amount_1 | payment_id2 | pay_type2  | amount_2 | payment_id3 | pay_type3 | amount_3
  5         | John       | Smith     | 1           | VISA      | $20      | 2           | Mastercard | $40      | 3           | AMEX      | $10
  </code></pre>
  
  <p>A single row as a result, creating columns for each row in the payments table. Thanks!</p>