title: SQL append variable string to WHERE clause depending on condition
body: <p>So I am trying to create a SQL statement and I have some conditions. Basically the user inputs (by a HTML form in JSP) semester and if it's graduate or undergraduate course, then a list of all courses in that criteria is shown.</p>
  
  <p>What I have so far is this</p>
  
  <pre><code>SELECT course
  FROM coursetable
  WHERE semester = 'fall'
  </code></pre>
  
  <p>Now I want to add that if you type in graduate, then it will add</p>
  
  <pre><code>WHERE semester ='fall'
  AND grad_level = graduate
  </code></pre>
  
  <p>but if you type in undergraduate, then it will add</p>
  
  <pre><code>WHERE semester ='fall'
  AND grad_level = undergraduate
  </code></pre>