我有一个应用程序,它根据来自 5 个文本字段的信息将信息存储在数据库中。我无法对字段进行排序,甚至无法从一个字段中进行排序。另外,ORDER BY 子句进入什么方法?数据库的代码片段如下:
public static final String MYDATABASE_NAME = "MY_DATABASE";
public static final String MYDATABASE_TABLE = "MY_TABLE";
public static final int MYDATABASE_VERSION = 1;
public static final String KEY_CONTENT = "Content";
public static final String lastName = "lastName";
public static final String firstName = "firstName";
public static final String school = "school";
public static final String email = "email";
public static final String intrest = "intrest";
Cursor d = sqLiteDatabase.rawQuery("SELECT * from " + MYDATABASE_TABLE + "ORDER BY " + lastName + " ASC" , null);
while (d.moveToNext()) {
int sort = d.getColumnIndex(lastName);
int sort2 = d.getColumnIndex(intrest);
String lastName = d.getString(sort);
String intrest = d.getString(sort2);
System.out.println("GOT STUDENT " + lastName + " LIKES " + intrest);
}