【发布时间】:2020-08-30 12:38:07
【问题描述】:
为什么 IN 子句/运算符无法从表中检索 type1、type2 行?
这是写在 main.kt 文件中
//if i write here **var type="type1"** then the DAO fetches correct result
but i want to fetch both type1 and type2. So, I am writing it in following way
and then passing the "type" variable as "bind variable" in DAO
but nothing is fetched and the output is blank//
var type="'type1','type2'"
var sq = runBlocking {qdatabase(applicationContext).getquizdao().engquest(type).shuffled()}
这是用 DAO 编写的
@Query("SELECT * FROM tabledata WHERE Subject='English' AND Qtype IN(:types)")
suspend fun engquest(types:String):List<quizdata>
这是数据库。
Question|Subject| Qtype |
------ |-------|------ |
Quest1 |English| type1 |
Quest2 |English| type2 |
Quest3 |English| type3 |
【问题讨论】:
标签: java sql kotlin android-sqlite android-room