title: Creating columns of a table using the rows of another
body: <p>I'm working on my project in php [handling students attendance system]. I have a list of students along with their unique id[<code>jntuno</code>] and I need to create a database in mysql for storing the daily attendance of each student for each subject. So I created my tables in this way :</p>
  <p>I have a table <code>students</code> in mysql with the following fields and data in it :</p>
  <p><img src="https://i.stack.imgur.com/UCrjV.jpg" alt="my table contents" /></p>
  <p>now I want to create a new table with the each of the values in the <code>jntuno</code> field as a columns of my new table.</p>
  <p>I want my new table [let us name it <code>attendance</code>] to have columns like this :</p>
  <pre><code>+------------+-----------+----------+-----------+-----------+
  |11341A0501  |11341A0502 |11341A0503|11341A0504 |11341A0505 |......      
  +------------+-----------+----------+-----------+-----------+
  |            |           |          |           |           |
  </code></pre>
  <p><strong>How to do this in mysql ?</strong></p>
  <p>I will later add 3  fields to the <code>attendance</code> table namely  :</p>
  <p>-&gt;  <code>date</code>[the date on which a particular subject is taught] ,</p>
  <p>-&gt;<code>subject</code>[the name of the subject taught] and</p>
  <p>-&gt;<code>hours taught</code>[the number of hours for which a particular subject is taught(can be 1 or 2 or 3 ... upto 6)]</p>
  <p>every <code>subject</code> taught on a particular <code>date</code> will be adding a new <code>row</code> to the <code>attendance</code> table</p>
  <p><strong>Example:</strong></p>
  <pre><code>+------------+-----------+-----------------+------------+-----------+----------+-----------+-----------+
  |date        |subject    | classes taught  |11341A0501  |11341A0502 |11341A0503|11341A0504 |11341A0505 |..    
  +------------+-----------+-----------------+------------+-----------+----------+-----------+-----------+
  |2013-09-31  |OOPS       |3                |2           |3          |0         |1          |3          |
  </code></pre>
  <p>I choose the tables in this way so that the entry of attendance into the table would be more faster.</p>
  <p>But many call this a <strong>BAD DATABASE STRUCTURE</strong> . So  please suggest me if there's some other good and efficient database design for my problem</p>