title: Sorting words using rawquery
body: <p>I want to be able to sort words in ascending order using raw query (since I will be using a cursor). However, when I tried to sorting the words alphabetically, my app crashed, giving me this error:</p>
  
  <pre><code>android.database.sqlite.SQLiteException: near "SELECTWORDFROM": syntax error (code 1): , while compiling: SELECTWORDFROM WORDSORDER BYWORD
  </code></pre>
  
  <p>The following shows the code where the error occured.</p>
  
  <p><strong>WordsDataSource.java</strong></p>
  
  <pre><code>public Cursor sortWords (){
          String[] wordname = new String[]{ WordsHelper.COLUMN_WORD };
          Cursor cursor = mDatabase.rawQuery
              ("SELECT"+ TextUtils.join(", ", wordname)+"FROM " +
                      WordsHelper.TABLE_WORDS +
                      "ORDER BY"+ TextUtils.join(", ", wordname),null);
          //Cursor cursor= mDatabase.query(WordsHelper.TABLE_WORDS,wordname , null, null, null, null, WordsHelper.COLUMN_WORD+" ASC");
  
  return cursor;
      }
  </code></pre>
  
  <p><strong>WordsHelper.java (my actual database)</strong></p>
  
  <pre><code>package mapp.com.sg.pocketdictionary.db;
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  public class WordsHelper extends SQLiteOpenHelper {
      public static final String TABLE_WORDS ="WORDS";
      public static final String COLUMN_ID = "_ID";
      public static final String COLUMN_WORD = "WORD";
      public static final String COLUMN_MEANING = "MEANING";
      public static final String COLUMN_TYPE = "TYPE";
      public static final String COLUMN_FAVOURITE = "FAVOURITE";
  
      private static final String DB_NAME = "words.db";
      private static final int DB_VER = 1;
      private static final String DB_CREATE = "CREATE TABLE "+TABLE_WORDS+
              " (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT" +
              ", " + COLUMN_WORD + " TEXT, "  +
              COLUMN_MEANING + " TEXT,"+
              COLUMN_TYPE + " TEXT,"+ COLUMN_FAVOURITE +" INTEGER)";
  
  
      public WordsHelper(Context context){
          super(context, DB_NAME, null, DB_VER);
  
      }
  
      @Override
      public void onCreate(SQLiteDatabase sqLiteDatabase) {
          sqLiteDatabase.execSQL(DB_CREATE);
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
  
      }
  }
  </code></pre>
  
  <p>Where did I go wrong?</p>