在SqLite Android中进行内部联接时获取空列表

时间:2016-10-01 02:25:23

标签: android sqlite join android-sqlite

我有两个表定义为:

sqLiteDatabase.execSQL(
                "create table medicine " +
                        "(medId INTEGER PRIMARY KEY , medName TEXT NOT NULL, imgPath TEXT NOT NULL, alarmScheduleDate INTEGER NOT NULL, lastDateForAlarm INTEGER NOT NULL )"
       );



sqLiteDatabase.execSQL(
                "create table reminderinfo " +
                        "(remId INTEGER PRIMARY KEY , medId INTEGER NOT NULL, remTime INTEGER NOT NULL," +
                        " medDose INTEGER NOT NULL, medCatogory TEXT NOT NULL," +
                        "foreign key(medId) REFERENCES medicine(medId))"
        );

我想使用具有某些条件的内部联接来加入这两个表。

在medId上加入这两个表,其中medCatogory = userinput

我的尝试:

String rawQuery = "SELECT * FROM medicine INNER JOIN reminderinfo ON medicine.medId = reminderinfo.medId WHERE reminderinfo.medCatogory="+ selectedCatagory;

db.rawQuery(rawQuery,null);

结果: -

  

android.database.sqlite.SQLiteException:没有这样的列:userinput   (代码1):,同时编译:SELECT * FROM medicine INNER JOIN   提醒信息ON medicine.medId = reminderinfo.medId在哪里   reminderinfo.medCatogory = userinput

userinput是用户提供的类别名称

案例2: -

String rawQuery = "SELECT * FROM medicine INNER JOIN reminderinfo ON medicine.medId = reminderinfo.medId 

获取空数组。

我已经使用SQLitebrowser尝试了这两个查询 并获得理想的结果

0 个答案:

没有答案