1

sqlite に 2 つのテーブルがあり、それらの両方のフィールドが必要ですが、何も得られませんでした。私はスタックオーバーフローで多くのことを試しましたが、誰も私のために働いていません..私のクエリはそのようなものです-

public List<HeadItemGroup> getAllExpense() {
            List<HeadItemGroup> expenseList = new ArrayList<HeadItemGroup>();
            db = sqlHp.getReadableDatabase();
            String selectquery = "SELECT table_expense.item_id AS ID,table_item.item_id AS ID2,* FROM table_expense INNER JOIN table_item ON table_expense.item_id=table_item.item_id";
            System.out.println("selectquery value..."+selectquery);
            cursor = db.rawQuery(selectquery, null);

            while (cursor.moveToNext()) {
                    HeadItemGroup record = new HeadItemGroup();
                    record.setExpId(cursor.getInt(cursor.getColumnIndex(EXPENCE_ID)));
                    record.setItemId(cursor.getInt(cursor.getColumnIndex(ITEM_ID)));
                    record.setHeadId(cursor.getInt(cursor.getColumnIndex(HEAD_ID)));
                    record.setDate(cursor.getString(cursor.getColumnIndex(EXPENCE_DATE)));
                    record.setPrice(cursor.getString(cursor.getColumnIndex(EXPENCE_PRICE)));
                    record.setLocationLat(cursor.getString(cursor.getColumnIndex(LOCATION_LAT)));
                    record.setLocationLon(cursor.getString(cursor.getColumnIndex(LOCATION_LON)));
                    record.setLocationName(cursor.getString(cursor.getColumnIndex(LOCATION_NAME)));
                    record.setCurrency(cursor.getString(cursor.getColumnIndex(CURRENCY_SYMBOL)));
                    record.setDescription(cursor.getString(cursor.getColumnIndex(DESCRIPTION)));
                    record.setItemName(cursor.getString(cursor.getColumnIndex(ITEM_NAME)));
                    record.setGroupId(cursor.getInt(cursor.getColumnIndex(GROUP_ID)));

                    expenseList.add(record);
                    System.out.println("total value value**************"+ cursor.getString(cursor.getColumnIndex(EXPENCE_PRICE)));
                    System.out.println("total value value**************"+ cursor.getString(cursor.getColumnIndex(ITEM_NAME)));
                    System.out.println("total value value**************"+ cursor.getString(cursor.getColumnIndex(GROUP_ID)));
            }

            return expenseList;
        }

そして、私が左外部結合のために同じテーブルを試しているとき、それは仕事です..

String selectquery="select exp_id as _id, * from table_expense d left outer join table_item  u on ( d.item_id=u.item_id)";

しかし、両方のテーブルのすべてのデータが必要です。私を助けてください...

4

0 に答える 0