title: Inserting a list into a single column in Mysql
body: <p>I have something like that:</p>
  
  <ul>
  <li><code>Course</code>: CID - CName </li>
  <li><code>Discipline</code>: MID - MNamev - MProf</li>
  </ul>
  
  <p>I have to create a list of disciplines, because one course will have more than one. So I followed this <a href="https://stackoverflow.com/questions/444251/how-to-store-a-list-in-a-db-column">link</a> and created a third table, just like that:</p>
  
  <pre><code>CREATE TABLE coursedisciplines (
  courseID int references curso (CID),
  disciplineID int references materias (MID),
  constraint pkcoursedis primary key (courseID, disciplineID)
  )
  </code></pre>
  
  <p>I'm able to add Data for the first table (course) and for the second (discipline). Sadly, when trying to connect them using the third, I get an error about the syntax. I looked for documentation but haven't found what I'm looking for. Here it's part if the code.</p>
  
  <pre><code>id = cmd.LastInsertedId;
  
  try
  {
      cmd.CommandText = "INSERT INTO materias(MName, MProf) VALUES (@MName, @MProf)";
      cmd.Parameters.AddWithValue("@MName", txtMName.Text);
      cmd.Parameters.AddWithValue("@MProf", txtMProf.Text);
  
      cmd.ExecuteNonQuery();
  
      //The error is below
      cmd.CommandText = "INSERT INTO coursedisciplines(courseID, disciplineID) VALUES(id, SELECT MID FROM discipline WHERE MName = '"+ txtMName.Text +"')"; 
      cmd.ExecuteNonQuery();
  }
  </code></pre>
  
  <p>Do you guys know what is wrong? Is this method really bad? I read a bit about serialize but don't want to go this way.</p>
  
  <p><strong>EDIT</strong> It worked here. Had to use select insert instead of select values. Thanks!</p>