如何使用通过 kotlin 传递的相同参数为 IN 子句使用多个值

How to use multiple values for IN clause using same parameter passed through kotlin

为什么 IN clause/operator 无法从 table 检索 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 |

您必须传递数组或类型列表:

var type = listOf("type1", "type2")
var  sq = runBlocking {qdatabase(applicationContext).getquizdao().engquest(type).shuffled()}
@Query("SELECT * FROM tabledata WHERE Subject='English' AND Qtype IN(:types)")
suspend fun engquest(types:List<String>):List<quizdata>