title: How to Display rows as Columns in MySQL?
body: <p>Guys I've table called <strong>beneficiaryloans</strong> as follows</p>
  
  <pre>
  +----+----------------+--------+--------+------+--------+-----------+
  | id | beneficiary_id | hfi_id | amount | rate | period | status_id |
  +----+----------------+--------+--------+------+--------+-----------+
  | 15 |             37 |    116 |    123 |  123 |    123 |         4 |
  | 16 |             38 |    117 |    123 |  123 |    123 |         4 |
  | 17 |             39 |    116 |    123 |  123 |    123 |         4 |
  +----+----------------+--------+--------+------+--------+-----------+
  </pre>
  
  <p>I want to Display It as follows based on <strong>Hfi_id</strong></p>
  
  <pre>
  +-----------------+---------------------------+
  | beneficiary_id  | hfi_id_116 | hfi_id_117   |
  +-----------------+----------------------------
  | 37              |  True      |    False     |
  | 38              |  False     |    True      |
  | 39              |  True      |    False     |
  +----------------------------------------------
  </pre>
  
  <p>How to do this in MySQL?</p>
  
  <p><strong>Note:</strong> Here I posted some of rows, and <strong>hfi_ids</strong> are keep stamping in this table, if <strong>3 hfi_id</strong> then i need <strong>3 columns</strong>, if 4 <strong>hfi_ids</strong> then i need <strong>4 columns</strong> and so on </p>