title: near "WHERE": syntax error - SQLite
body: <p>I have a method that will if check two text fields exist then retune the record ID. 
  My method look like this: </p>
  
  <pre><code>int getQueryMatch(String word, String meter) {
      SQLiteDatabase db = this.getReadableDatabase();
  
      String selectQuery = "SELECT *  FROM " + TABLE_HISTORY + " WHERE " + QUERYWORD +  "= '" + word + "' AND WHERE " + DISTANCEQ + "= '"+ meter +"' "  ;
      Cursor cursor = db.rawQuery(selectQuery, null);
      int getidd = cursor.getColumnIndex(KEY_ID) ;
  
  
      Log.v("Match query ", "return? " + getidd );
      if (cursor != null)
          cursor.moveToFirst();
  
      // return History
      return getidd;
  }
  </code></pre>
  
  <p>and I have my table looks like this: </p>
  
  <pre><code>    String CREATE_HISTORYS_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_HISTORY + "(" + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
              QUERYWORD + " TEXT," + DISTANCEQ + " TEXT" + ","  + KEY_TIMESTAMP + ")";
      db.execSQL(CREATE_HISTORYS_TABLE);
  </code></pre>
  
  <p>now when I run the method as if getQueryMatch(Mystr1 , Mystr2); </p>
  
  <p>I got this error: </p>
  
  <pre><code>10-18 22:04:04.294: E/AndroidRuntime(13736): FATAL EXCEPTION: AsyncTask #1
  10-18 22:04:04.294: E/AndroidRuntime(13736): java.lang.RuntimeException: An error occured while executing doInBackground()
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.lang.Thread.run(Thread.java:856)
  10-18 22:04:04.294: E/AndroidRuntime(13736): Caused by: ****android.database.sqlite.SQLiteException: near "WHERE": syntax error (code 1): , while compiling: SELECT *  FROM history WHERE query= 'Information Pillar' AND WHERE distance= '20'****
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:58)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteQuery.&lt;init&gt;(SQLiteQuery.java:37)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at com.example.phooogle.DatabaseHandler.getQueryMatch(DatabaseHandler.java:149)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at com.example.phooogle.GoogleMapsAppActivity$InitTask.doInBackground(GoogleMapsAppActivity.java:233)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at com.example.phooogle.GoogleMapsAppActivity$InitTask.doInBackground(GoogleMapsAppActivity.java:1)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
  10-18 22:04:04.294: E/AndroidRuntime(13736):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  </code></pre>
  
  <p>My select query looks like alright to me but I don't know what is the problem? </p>