android - sqlLiteDatabase.query() for INNER JOIN -
i want query follows android sqlite db:
select place.permit_name, local.local_distance tbllocal local inner join tblplaces place on place._id = local._id order local.local_distance asc
i'm trying use query()
, instead of rawquery()
. don't know how specify inner join/on. how do this?
final string table = placesdatacontract.placesdataentry.table_name; final string[] columns = { placesdatacontract.placesdataentry.column_name_permit_name. , localdatacontract.localdataentry.column_name_local_distance}; final string orderby = localdatacontract.localdataentry.column_name_local_distance + " asc"; cursor cursor = sqlitedatabase.query(table, // table columns, // columns null, // selection null, // selectionargs null, // groupby null, // having orderby, // orderby null); // limit
you can put join in table
variable.
string table = "tbllocal local " + "inner join tblplaces place " + "on place._id = local._id";
see iosched app google example. take @ provider package , selectionbuilder class.
a sqlitequerybuilder
used construct query string, , concatenate table variable rest of query. see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/database/sqlite/sqlitequerybuilder.java#201
Comments
Post a Comment