有没有办法检索从如下调用生成的原始查询字符串?我试图弄清楚“?” 占位符被填充。
Cursor cursor = database.query(
adapter.getTable(), // The table to query - String
adapter.getColumns(), // The columns to return - String[]
adapter.getWhereClause(), // The columns for the WHERE clause - String
adapter.getWhereClauseArgs(), // The values for the WHERE clause - String[]
null, // Group by - String
null, // Groups having - String
adapter.getSortBy(), // The sort order - String
adapter.getLimit()); // The limit - String
我很好奇操作的顺序。例如,如果上面的查询转换为下面带有 whereClause 参数的 select,我会得到 result1 还是 result2?它是否像数学中的运算顺序一样工作,括号中的语句首先执行?或者它是否严格依赖于字符串中“?”的位置。
String select = "SELECT * FROM table1 WHERE someField = ? AND _id in(SELECT _id FROM table2 WHERE status = ?)";
String[] args = new String[]{ "blue", "active" };
String result1 = "SELECT * FROM table1 WHERE someField = 'blue' AND _id in(SELECT _id FROM table2 WHERE status = 'active')";
String result2 = "SELECT * FROM table1 WHERE someField = 'active' AND _id in(SELECT _id FROM table2 WHERE status = 'blue')";