0

我想使用 WHERE 子句按升序检索所有记录。但是在我的查询中在哪里包含 WHERE 条件?它适用于升序。

这是我的代码。首先我正在处理这个查询,但在这里我无法实现 ORDER BY 子句。

Cursor tripdaycursor = sdb.rawQuery(
  "select TripDay_Id, Tripday_Date, Tripday_ParsingDate,
  Trip_Complete, TripDay_Endkm, TripDay_Count, Tripday_EndPlace
  FROM TripDay WHERE Trip_Id="+record, null);

所以我尝试了下面的代码升序:

String recordid=Integer.toString(record), Trip_Id="Trip_Id", TripDay_Id="TripDay_Id",
  Tripday_Date="Tripday_Date", Tripday_ParsingDate="Tripday_ParsingDate",
  Trip_Complete="Trip_Complete", TripDay_Endkm="TripDay_Endkm",
  TripDay_Count="TripDay_Count", Tripday_EndPlace="Tripday_EndPlace",
  TripDay = "TripDay";
Cursor tripdaycursor = sdb.query(TripDay, new String[] {
  TripDay_Id, Tripday_Date, Tripday_ParsingDate, Trip_Complete, TripDay_Endkm,
  TripDay_Count, Tripday_EndPlace}, null, null, null, null,
  Tripday_ParsingDate + " ASC");

但我希望在单个查询中同时使用 WHERE 子句并按升序排列这两个条件。怎么做?

4

1 回答 1

0

您可以在 where 子句之后的查询中添加“order by Column_Name”。像这样,您要按升序排列的列

Cursor tripdaycursor = sdb.rawQuery("select TripDay_Id,Tripday_Date,Tripday_ParsingDate,Trip_Complete,TripDay_Endkm,TripDay_Count,Tripday_EndPlace from TripDay where Trip_Id="+record + " order by " + columnName,null);
于 2013-01-10T06:38:59.470 回答