title: Pass List<string> Into SQL Parameter
body: <p>The program is in C#, and I'm trying to pass a <code>List&lt;string&gt;</code> as a parameter.</p>
  
  <pre><code>List&lt;string&gt; names = new List&lt;string&gt;{"john", "brian", "robert"};
  </code></pre>
  
  <p>In plain SQL, the query will look like this:</p>
  
  <pre><code>DELETE FROM Students
  WHERE name = 'john' or name = 'brian' or name = 'robert'
  </code></pre>
  
  <p>When running a SQL command in C# code, I know that the proper way of doing it is to use parameters instead of concatenating everything into one giant string.</p>
  
  <pre><code>command.CommmandText = "DELETE FROM Students WHERE name = @name";
  command.Parameters.Add(new MySqlParameter("@name", String.Format("'{0}'", String.Join("' or name = '", names)));
  command.NonQuery();
  </code></pre>
  
  <p>The above method did not work. It didn't throw any error/exception, it just simply didn't work the way I want it to.</p>
  
  <p><strong>How should I go about doing this?</strong></p>
  
  <p>I thought about looping through the <code>List&lt;string&gt;</code> and just execute on every single name. </p>
  
  <pre><code>foreach(string name in names)
  {
      command.CommmandText = "DELETE FROM Students WHERE name = @name";
      command.Parameters.Add(new MySqlParameter("@name", name));
      command.NonQuery();
      command.Parameters.Clear();
  }
  </code></pre>
  
  <p>But this will take a long time as the actual <code>List&lt;string&gt;</code> is quite large. I want to try execute at little as possible.</p>
  
  <p>Thanks! </p>