title: Column is either not in any table in the FROM list Java database searching
body: <p>I'm working on a database program in Java and I've run into a problem with it telling me that what I'm searching for is not located in the table.</p>
  
  <pre><code>public static void displayRecord(ResultSet rs) throws SQLException
  {
      String assignment = rs.getString("assignment");
      int grade = rs.getInt("grade");
      System.out.println(assignment + " | " + grade + "\n");
  }
  
  public void findGrade(String assignment){
  
      String assignString;
      int gradeInt;
  
      try{
          Class.forName(driver).newInstance();
      }
      catch (Exception err){
          System.err.println("Unable to load the embedded driver.");
          err.printStackTrace(System.err);
          System.exit(0);
      }
      Connection connected = null;
  
      try{
  
          int ble = 25;
          connected = DriverManager.getConnection(protocol + databaseName);
  
          Statement statement = connected.createStatement();
  
          ResultSet rs = null;
  
          rs = statement.executeQuery("SELECT assignment, grade FROM student WHERE assignment = " + assignment);
  
          if(rs == null ) {
              System.out.println("Assignment not found!");
          }
          else {
              displayRecord(rs);
          }
  
          rs.close();
  
          connected.close();
  
  
      }
  
      catch (SQLException err){
          System.err.println("SQL error.");
          err.printStackTrace(System.err);
          System.exit(0);
      }
  }
  </code></pre>
  
  <p>It ends up giving me the following error</p>
  
  <blockquote>
    <p>SQL error.
    java.sql.SQLSyntaxErrorException: Column 'ASSIGNMENT1' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'ASSIGNMENT1' is not a column in the target table.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown Source)
        at Student.findGrade(Student.java:153)
        at GradeBookTester.main(GradeBookTester.java:17)</p>
  </blockquote>
  
  <p>I am unsure why it is giving me the error as is exist in my database.</p>
  
  <p>I'll give the code for the tester and database creator itself to see if mistakes are made there but it all seems pretty solid.</p>
  
  <p>DataBase:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class CreateGradeBook{
  
  private static final String driver = "org.apache.derby.jdbc.EmbeddedDriver";
  private static final String protocol = "jdbc:derby:";
  
  public static void main(String[] args)
  {
      try{
          Class.forName(driver).newInstance();
          System.out.println("Loaded the embedded driver.");
      }
      catch (Exception err){
          System.err.println("Unable to load the embedded driver.");
          err.printStackTrace(System.err);
          System.exit(0);
      }
  
      String dbName = "GradeBook";
      Connection connected = null;
  
      try{
          System.out.println("connecting to and creating the database...");
          connected = DriverManager.getConnection(protocol + dbName + ";create=true");
          System.out.println("database created.");
  
          Statement statement = connected.createStatement();
  
          statement.execute("CREATE TABLE student" + "(student_name varchar(50), student_id int, assignment varchar(80), grade int)");
          System.out.println("created Student table.");
  
  
          connected.close();
      }
  
      catch (SQLException err){
          System.err.println("SQL error.");
          err.printStackTrace(System.err);
          System.exit(0);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and here is the code for the tester</p>
  
  <pre><code>public class GradeBookTester {
  
  public static void main(String[] args) {
      Student bob = new Student();
  
      bob.setStudentName("Bob");
      bob.setStudnetID(12345);
  
      bob.addGrade("ASSIGNMENT1", 100);
      bob.addGrade("assignment2", 50);
      bob.addGrade("assignment3", 25);
      bob.addGrade("assignment4", 100);
  
      bob.displayGrades();
  
      bob.findGrade("ASSIGNMENT1");
  }
  
  }
  </code></pre>