genreName", "Genres.category_id", "Categories.name as categoryName") .from(Genre.class) .innerJoin(Category.class) .on("Genres.category_id = Categories.category_id") .where("Genres.active = 1 and Categories.active = 1") .orderBy("Categories.sort, Genres.sort"); final Cursor cursor = Cache.openDatabase().rawQuery(query.toSql(), query.getArguments());