gpt4 book ai didi

java - 两个字段索引

转载 作者:行者123 更新时间:2023-12-02 04:39:07 25 4
gpt4 key购买 nike

我有下一个查询:

Cursor cursor = ES09SQLiteHelper.getDatabase()
.query(CompanyDomain.TABLE_NAME,
allColumns,
CompanyDomain.ADDRESS + " LIKE ? AND "
+ CompanyDomain.NAME + " LIKE ?",
new String[] { Cities.TATARSTAN + city + "%",
"%" + query + "%" }, null, null, null);

这意味着SELECT * FROM Companies WHERE address LIKE city% AND name LIKE %query%;我如何为此创建索引?我做了以下事情:

database.execSQL("CREATE INDEX company_address_index ON "
+ CompanyDomain.TABLE_NAME + "(" + CompanyDomain.ADDRESS
+ " COLLATE NOCASE)");

但是我的索引还应该包含一个字段。我怎样才能做到这一点?

最佳答案

database.execSQL("CREATE INDEX company_address_index ON "
+ CompanyDomain.TABLE_NAME + "(name, address
+ " COLLATE NOCASE)");

或者在普通的 SQLite 中:

CREATE INDEX [name-of-index] ON [table-name]([column1] , [column2] , ...)

关于java - 两个字段索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30391987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com