1
我有,我已经实现了搜索查看使用此查询通过其数据 搜索数据库:查询失败与多个条件
选择:
//rooms.name = ? OR rooms.name LIKE ? OR rooms.name LIKE ? OR rooms.name LIKE ?
private static final String roomsWithSectorsByNameSelection =
DeltaContract.RoomsEntry.TABLE_NAME +
"." + DeltaContract.RoomsEntry.COLUMN_NAME + " = ? OR " +
DeltaContract.RoomsEntry.TABLE_NAME +
"." + DeltaContract.RoomsEntry.COLUMN_NAME + " LIKE ? OR " +
DeltaContract.RoomsEntry.TABLE_NAME +
"." + DeltaContract.RoomsEntry.COLUMN_NAME + " LIKE ? OR " +
DeltaContract.RoomsEntry.TABLE_NAME +
"." + DeltaContract.RoomsEntry.COLUMN_NAME + " LIKE ?";
表:
roomsWithSectorsByNameQueryBuilder.setTables(
DeltaContract.RoomsEntry.TABLE_NAME + " INNER JOIN " +
DeltaContract.SectorsEntry.TABLE_NAME +
" ON " + DeltaContract.RoomsEntry.TABLE_NAME +
"." + DeltaContract.RoomsEntry.COLUMN_SECTOR_ID + " = " +
DeltaContract.SectorsEntry.TABLE_NAME +
"." + DeltaContract.SectorsEntry._ID);
和查询:
private Cursor getRoomsWithSectorsByName(Uri uri, String[] projection, String sortOrder) {
String name = DeltaContract.RoomsEntry.getNameFromRoomsUri(uri);
return roomsWithSectorsByNameQueryBuilder.query(deltaDbHelper.getReadableDatabase(),
projection,
roomsWithSectorsByNameSelection,
new String[]{name, (name + "%"), ("%" + name + "%"), ("%" + name)},
DeltaContract.SectorsEntry.TABLE_NAME + "." + DeltaContract.SectorsEntry.COLUMN_NAME,
null,
sortOrder
);
}
大多数搜索我尝试它工作出色,但对于某些行,即使我键入整个单词
但
,如果我选择改变这一点,不工作:
//rooms.name = ?
private static final String roomsWithSectorsByNameSelection =
DeltaContract.RoomsEntry.TABLE_NAME +
"." + DeltaContract.RoomsEntry.COLUMN_NAME + " = ?";
,并查询到这一点:
private Cursor getRoomsWithSectorsByName(Uri uri, String[] projection, String sortOrder) {
String name = DeltaContract.RoomsEntry.getNameFromRoomsUri(uri);
return roomsWithSectorsByNameQueryBuilder.query(deltaDbHelper.getReadableDatabase(),
projection,
roomsWithSectorsByNameSelection,
new String[]{name},
DeltaContract.SectorsEntry.TABLE_NAME + "." + DeltaContract.SectorsEntry.COLUMN_NAME,
null,
sortOrder
);
}
删除所有喜欢,它工作正常,
应该注意的是,如果我使用不同的列的第一个查询无法找到该行查找表,它的工作原理和返回行
还应该注意的是,行中的数据是以阿拉伯语存储的
所以有什么帮助吗?谢谢
编辑
例如: 在第一状态具有所有喜欢的查询,当我搜索“رئيسمجلسالإدارة”这是这里显示的第一行:
(图像号之一)
按名称搜索,只得到类似的行:
(图像编号二)
但是当我按电话号码搜索找到它:
(图像之三)
即使我写在阿拉伯语中的电话号码:
(图像排名第四)
这里是图片(由于低信誉造成的限制,将它们放在一个链接中)
现在,当我更改查询并删除所有喜欢它只是发现它:
还应该注意的问题并不局限于此行,它没有与其它行也发生遵循同样的行为
显示一些示例数据。 –
[如何 格式化堆栈溢出中的SQL表格 post?](https://meta.stackexchange.com/q/96125) –
@CL。 [这是我的数据库中的表格](http://pho.to/AhR9z) 无法在该网站中做到这一点导致阿拉伯语rtl对齐搞砸了 –